QueryFlags don't use =

* Also, fix import for old `Servant` versions - _every_ version now needs `Data.Bytestring` (i.e. Servant version < 0.8, as per old lts in `stack.yaml`)
This commit is contained in:
Nick B 2017-03-10 08:31:56 +00:00
parent 77fa490b93
commit 2109326ad7
2 changed files with 3 additions and 5 deletions

View File

@ -15,9 +15,8 @@ import Servant
import Servant.API.ContentTypes (AllMimeRender (..))
import Servant.Client (BaseUrl (..), Scheme (..))
import Test.QuickCheck (Arbitrary (..), Gen, elements, oneof)
#if MIN_VERSION_servant(0,8,0)
import qualified Data.ByteString as BS
#endif
class HasGenRequest a where
@ -120,9 +119,8 @@ instance (KnownSymbol x, HasGenRequest b)
genRequest _ = do
old' <- old
return $ \burl -> let r = old' burl
newExpr = param <> "="
qs = queryString r in r {
queryString = if BS.null qs then newExpr else newExpr <> "&" <> qs }
queryString = if BS.null qs then param else param <> "&" <> qs }
where
old = genRequest (Proxy :: Proxy b)
param = cs $ symbolVal (Proxy :: Proxy x)

View File

@ -133,7 +133,7 @@ queryFlagsSpec = describe "QueryFlags" $ do
gen = genRequest flagsAPI
req = (unGen gen rng 0) burl
qs = C.unpack $ queryString req
qs `shouldBe` "one=&two="
qs `shouldBe` "one&two"
------------------------------------------------------------------------------
-- APIs