http-api-data-qq 0.1.0.0 → 0.1.0.1
raw patch · 7 files changed
+55/−52 lines, 7 filesdep −aesondep −containersdep ~http-api-datadep ~tasty-hunitdep ~tasty-quickcheckPVP ok
version bump matches the API change (PVP)
Dependencies removed: aeson, containers
Dependency ranges changed: http-api-data, tasty-hunit, tasty-quickcheck, template-haskell, text
API changes (from Hackage documentation)
Files
- CHANGELOG.md +4/−2
- README.md +1/−1
- http-api-data-qq.cabal +15/−13
- src/Web/HttpApiData/QQ.hs +10/−11
- src/Web/HttpApiData/QQ/Parser.hs +1/−1
- test/Web/HttpApiData/QQ/ParserTest.hs +12/−13
- test/Web/HttpApiData/QQTest.hs +12/−11
CHANGELOG.md view
@@ -1,5 +1,7 @@-# Unreleased+# v0.1.0.1 -# 0.1.0.0+* Skip flaky httpbin.org test++# v0.1.0.0 * Initial release
README.md view
@@ -1,6 +1,6 @@ # `http-api-data-qq` -[](https://app.circleci.com/pipelines/github/brandonchinn178/http-api-data-qq)+[](https://github.com/brandonchinn178/http-api-data-qq/actions/workflows/ci.yml?query=branch%3Amain) [](https://hackage.haskell.org/package/http-api-data-qq) [](https://codecov.io/gh/brandonchinn178/http-api-data-qq)
http-api-data-qq.cabal view
@@ -1,11 +1,11 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.34.4.+-- This file has been generated from package.yaml by hpack version 0.38.1. -- -- see: https://github.com/sol/hpack name: http-api-data-qq-version: 0.1.0.0+version: 0.1.0.1 synopsis: Quasiquoter for building URLs with ToHttpApiData types description: Quasiquoter for building URLs with strings interpolated using ToHttpApiData instances@@ -32,13 +32,15 @@ Paths_http_api_data_qq hs-source-dirs: src- ghc-options: -Wall+ ghc-options: -Wall -Wcompat build-depends:- base >=4.12 && <4.17- , http-api-data >=0.4.1.1 && <0.5- , template-haskell >=2.14 && <2.19- , text >=1.2.3.1 && <1.3+ base >=4.12 && <5+ , http-api-data <0.7+ , template-haskell <2.24+ , text <2.2 default-language: Haskell2010+ if impl(ghc >= 8.10)+ ghc-options: -Wunused-packages test-suite http-api-data-qq-test type: exitcode-stdio-1.0@@ -49,17 +51,17 @@ Paths_http_api_data_qq hs-source-dirs: test- ghc-options: -Wall+ ghc-options: -Wall -Wcompat build-depends:- aeson- , base+ base , bytestring- , containers , http-api-data , http-api-data-qq , http-client , tasty- , tasty-hunit- , tasty-quickcheck+ , tasty-hunit >=0.10+ , tasty-quickcheck >=0.8.1 , text default-language: Haskell2010+ if impl(ghc >= 8.10)+ ghc-options: -Wunused-packages
src/Web/HttpApiData/QQ.hs view
@@ -13,17 +13,16 @@ import Web.HttpApiData.QQ.Parser -{- |-A quasiquoter to build a URL by interpolating values via ToHttpApiData.-The resulting value can be any IsString type.--Currently only supports single variable names being interpolated, not-arbitrary Haskell expressions.--Usage:-->>> [url|/foo/#{fooId}/bar|]--}+-- |+-- A quasiquoter to build a URL by interpolating values via ToHttpApiData.+-- The resulting value can be any IsString type.+--+-- Currently only supports single variable names being interpolated, not+-- arbitrary Haskell expressions.+--+-- Usage:+--+-- >>> [url|/foo/#{fooId}/bar|] url :: QuasiQuoter url = QuasiQuoter
src/Web/HttpApiData/QQ/Parser.hs view
@@ -29,7 +29,7 @@ readable than ReadP's API. --} -runParser :: Show a => ReadP a -> String -> Either String a+runParser :: (Show a) => ReadP a -> String -> Either String a runParser p s = case filter (null . snd) (readP_to_S p s) of [(x, "")] -> Right x
test/Web/HttpApiData/QQ/ParserTest.hs view
@@ -31,19 +31,18 @@ in parseUrlPieces input === Right expected ] -{- |-For two generators A and B, generates a list where each element-alternates between the two generators.--e.g.- * []- * [A]- * [B]- * [A, B]- * [B, A]- * [A, B, A]- * [B, A, B]--}+-- |+-- For two generators A and B, generates a list where each element+-- alternates between the two generators.+--+-- e.g.+-- * []+-- * [A]+-- * [B]+-- * [A, B]+-- * [B, A]+-- * [A, B, A]+-- * [B, A, B] alternatingListOf :: Gen a -> Gen a -> Gen [a] alternatingListOf genA genB = do startOnB <- arbitrary
test/Web/HttpApiData/QQTest.hs view
@@ -6,21 +6,15 @@ module Web.HttpApiData.QQTest (tests) where -import qualified Data.Aeson as Aeson import Data.ByteString (ByteString)+import qualified Data.ByteString.Char8 as Char8 import qualified Data.ByteString.Lazy as Lazy (ByteString)-import qualified Data.Map as Map import Data.String (IsString, fromString) import Data.Text (Text) import qualified Data.Text as Text import qualified Data.Text.Lazy as Lazy (Text)-import Network.HTTP.Client (- Response (..),- defaultManagerSettings,- httpLbs,- newManager,- parseRequest,- )+import Network.HTTP.Client (parseRequest)+import qualified Network.HTTP.Client as HTTP import Test.Tasty (TestTree, testGroup) import Test.Tasty.HUnit import Web.HttpApiData (ToHttpApiData (..))@@ -38,7 +32,9 @@ [url|/foo/#{asdf}/baz|] @?= "/foo/bar/baz" , testCase "Quasiquoter generates any IsString" $ do let check :: forall a. (Eq a, IsString a, Show a) => Assertion- check = [url|/foo|] @?= (fromString "/foo" :: a)+ check = do+ let asdf = "test"+ [url|/foo/#{asdf}|] @?= (fromString "/foo/test" :: a) check @String check @Text check @Lazy.Text@@ -48,14 +44,19 @@ let path = PathHello [url|#{path}/1|] @?= "/hello/1" , testCase "Can be used with http-client" $ do- manager <- newManager defaultManagerSettings let userId = 100 :: Int request <- parseRequest [url|http://httpbin.org/anything/user/#{userId}|]++ -- httpbin is timing out: https://github.com/postmanlabs/httpbin/issues/703+ {-+ manager <- newManager defaultManagerSettings response <- responseBody <$> httpLbs request manager body <- maybe (assertFailure $ "Response could not be decoded: " ++ show response) return $ Aeson.decode response "url" `Map.lookup` body @?= Just (Aeson.toJSON "http://httpbin.org/anything/user/100")+ -}+ HTTP.path request @?= Char8.pack "/anything/user/100" ] data MyPath = PathHello | PathWorld