Test whole list in CaptureAll client tests
This commit is contained in:
parent
ed702f5927
commit
d945c99f82
1 changed files with 5 additions and 4 deletions
|
@ -105,7 +105,7 @@ type Api =
|
||||||
"get" :> Get '[JSON] Person
|
"get" :> Get '[JSON] Person
|
||||||
:<|> "deleteEmpty" :> DeleteNoContent '[JSON] NoContent
|
:<|> "deleteEmpty" :> DeleteNoContent '[JSON] NoContent
|
||||||
:<|> "capture" :> Capture "name" String :> Get '[JSON,FormUrlEncoded] Person
|
:<|> "capture" :> Capture "name" String :> Get '[JSON,FormUrlEncoded] Person
|
||||||
:<|> "captureAll" :> CaptureAll "names" String :> Get '[JSON] Person
|
:<|> "captureAll" :> CaptureAll "names" String :> Get '[JSON] [Person]
|
||||||
:<|> "body" :> ReqBody '[FormUrlEncoded,JSON] Person :> Post '[JSON] Person
|
:<|> "body" :> ReqBody '[FormUrlEncoded,JSON] Person :> Post '[JSON] Person
|
||||||
:<|> "param" :> QueryParam "name" String :> Get '[FormUrlEncoded,JSON] Person
|
:<|> "param" :> QueryParam "name" String :> Get '[FormUrlEncoded,JSON] Person
|
||||||
:<|> "params" :> QueryParams "names" String :> Get '[JSON] [Person]
|
:<|> "params" :> QueryParams "names" String :> Get '[JSON] [Person]
|
||||||
|
@ -126,7 +126,7 @@ api = Proxy
|
||||||
getGet :: C.Manager -> BaseUrl -> SCR.ClientM Person
|
getGet :: C.Manager -> BaseUrl -> SCR.ClientM Person
|
||||||
getDeleteEmpty :: C.Manager -> BaseUrl -> SCR.ClientM NoContent
|
getDeleteEmpty :: C.Manager -> BaseUrl -> SCR.ClientM NoContent
|
||||||
getCapture :: String -> C.Manager -> BaseUrl -> SCR.ClientM Person
|
getCapture :: String -> C.Manager -> BaseUrl -> SCR.ClientM Person
|
||||||
getCaptureAll :: [String] -> C.Manager -> BaseUrl -> SCR.ClientM Person
|
getCaptureAll :: [String] -> C.Manager -> BaseUrl -> SCR.ClientM [Person]
|
||||||
getBody :: Person -> C.Manager -> BaseUrl -> SCR.ClientM Person
|
getBody :: Person -> C.Manager -> BaseUrl -> SCR.ClientM Person
|
||||||
getQueryParam :: Maybe String -> C.Manager -> BaseUrl -> SCR.ClientM Person
|
getQueryParam :: Maybe String -> C.Manager -> BaseUrl -> SCR.ClientM Person
|
||||||
getQueryParams :: [String] -> C.Manager -> BaseUrl -> SCR.ClientM [Person]
|
getQueryParams :: [String] -> C.Manager -> BaseUrl -> SCR.ClientM [Person]
|
||||||
|
@ -158,7 +158,7 @@ server = serve api (
|
||||||
return alice
|
return alice
|
||||||
:<|> return NoContent
|
:<|> return NoContent
|
||||||
:<|> (\ name -> return $ Person name 0)
|
:<|> (\ name -> return $ Person name 0)
|
||||||
:<|> (\ (name : _) -> return $ Person name 0)
|
:<|> (\ names -> return (zipWith Person names [0..]))
|
||||||
:<|> return
|
:<|> return
|
||||||
:<|> (\ name -> case name of
|
:<|> (\ name -> case name of
|
||||||
Just "alice" -> return alice
|
Just "alice" -> return alice
|
||||||
|
@ -255,7 +255,8 @@ sucessSpec = beforeAll (startWaiApp server) $ afterAll endWaiApp $ do
|
||||||
(left show <$> runExceptT (getCapture "Paula" manager baseUrl)) `shouldReturn` Right (Person "Paula" 0)
|
(left show <$> runExceptT (getCapture "Paula" manager baseUrl)) `shouldReturn` Right (Person "Paula" 0)
|
||||||
|
|
||||||
it "Servant.API.CaptureAll" $ \(_, baseUrl) -> do
|
it "Servant.API.CaptureAll" $ \(_, baseUrl) -> do
|
||||||
(left show <$> runExceptT (getCaptureAll ["Paula", "Peta"] manager baseUrl)) `shouldReturn` Right (Person "Paula" 0)
|
let expected = [(Person "Paula" 0), (Person "Peta" 1)]
|
||||||
|
(left show <$> runExceptT (getCaptureAll ["Paula", "Peta"] manager baseUrl)) `shouldReturn` Right expected
|
||||||
|
|
||||||
it "Servant.API.ReqBody" $ \(_, baseUrl) -> do
|
it "Servant.API.ReqBody" $ \(_, baseUrl) -> do
|
||||||
let p = Person "Clara" 42
|
let p = Person "Clara" 42
|
||||||
|
|
Loading…
Reference in a new issue