diff --git a/lib/SlackBuilder/Package.hs b/lib/SlackBuilder/Package.hs index a447609..bd53447 100644 --- a/lib/SlackBuilder/Package.hs +++ b/lib/SlackBuilder/Package.hs @@ -68,8 +68,8 @@ renderDownloadWithVersion :: MonadThrow m => DownloadTemplate -> Text -> m URI renderDownloadWithVersion (DownloadTemplate components) version = URI.mkURI $ foldr f "" components where - f (StaticPlaceholder staticPlaceholder) accumulator = accumulator <> staticPlaceholder - f VersionPlaceholder accumulator = accumulator <> version + f (StaticPlaceholder staticPlaceholder) = (staticPlaceholder <>) + f VersionPlaceholder = (version <>) -- | Function used to get the latest version of a source. data Updater = Updater (SlackBuilderT (Maybe Text)) DownloadTemplate diff --git a/slackbuilder.cabal b/slackbuilder.cabal index 5f0c5e2..bc20b51 100644 --- a/slackbuilder.cabal +++ b/slackbuilder.cabal @@ -16,7 +16,6 @@ category: Build extra-source-files: CHANGELOG.md common dependencies - ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall build-depends: base ^>= 4.16.4.0, cryptonite >= 0.30, @@ -47,6 +46,8 @@ library slackbuilder-internal tomland ^>= 1.3.3, transformers ^>= 0.5.6 + ghc-options: -Wall + executable slackbuilder import: dependencies main-is: Main.hs @@ -67,6 +68,8 @@ executable slackbuilder vector ^>= 0.13.0 hs-source-dirs: app + ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall + test-suite slackbuilder-test import: dependencies type: exitcode-stdio-1.0 @@ -78,3 +81,5 @@ test-suite slackbuilder-test build-depends: hspec >= 2.10.9 && < 2.12, slackbuilder-internal + + ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall diff --git a/tests/SlackBuilder/PackageSpec.hs b/tests/SlackBuilder/PackageSpec.hs index 82d9a87..ffe6737 100644 --- a/tests/SlackBuilder/PackageSpec.hs +++ b/tests/SlackBuilder/PackageSpec.hs @@ -2,13 +2,14 @@ module SlackBuilder.PackageSpec ( spec ) where +import Data.List.NonEmpty (NonEmpty(..)) import SlackBuilder.Package import Test.Hspec (Spec, describe, it, shouldBe) import Text.URI.QQ (uri) spec :: Spec spec = do - describe "renderDownloadWithVersion" $ + describe "renderDownloadWithVersion" $ do it "renders text as URL" $ let given = DownloadTemplate $ pure @@ -16,3 +17,11 @@ spec = do actual = renderDownloadWithVersion given "1.2" expected = Just [uri|https://example.com|] in actual `shouldBe` expected + + it "renders the components in order" $ + let given = DownloadTemplate + $ StaticPlaceholder "https://example.com/" + :| [VersionPlaceholder, StaticPlaceholder "/segment"] + actual = renderDownloadWithVersion given "1.2" + expected = Just [uri|https://example.com/1.2/segment|] + in actual `shouldBe` expected