Add test for 'Delete'
This commit is contained in:
parent
56e68bc737
commit
e5db50917b
1 changed files with 7 additions and 0 deletions
|
@ -45,6 +45,7 @@ alice = Person "Alice" 42
|
||||||
|
|
||||||
type Api =
|
type Api =
|
||||||
"get" :> Get Person
|
"get" :> Get Person
|
||||||
|
:<|> "delete" :> Delete
|
||||||
:<|> "capture" :> Capture "name" String :> Get Person
|
:<|> "capture" :> Capture "name" String :> Get Person
|
||||||
:<|> "body" :> ReqBody Person :> Post Person
|
:<|> "body" :> ReqBody Person :> Post Person
|
||||||
:<|> "param" :> QueryParam "name" String :> Get Person
|
:<|> "param" :> QueryParam "name" String :> Get Person
|
||||||
|
@ -67,6 +68,7 @@ api = Proxy
|
||||||
server :: Application
|
server :: Application
|
||||||
server = serve api (
|
server = serve api (
|
||||||
return alice
|
return alice
|
||||||
|
:<|> return ()
|
||||||
:<|> (\ name -> return $ Person name 0)
|
:<|> (\ name -> return $ Person name 0)
|
||||||
:<|> return
|
:<|> return
|
||||||
:<|> (\ name -> case name of
|
:<|> (\ name -> case name of
|
||||||
|
@ -90,6 +92,7 @@ withServer :: (BaseUrl -> IO a) -> IO a
|
||||||
withServer action = withWaiDaemon (return server) action
|
withServer action = withWaiDaemon (return server) action
|
||||||
|
|
||||||
getGet :: BaseUrl -> EitherT String IO Person
|
getGet :: BaseUrl -> EitherT String IO Person
|
||||||
|
getDelete :: BaseUrl -> EitherT String IO ()
|
||||||
getCapture :: String -> BaseUrl -> EitherT String IO Person
|
getCapture :: String -> BaseUrl -> EitherT String IO Person
|
||||||
getBody :: Person -> BaseUrl -> EitherT String IO Person
|
getBody :: Person -> BaseUrl -> EitherT String IO Person
|
||||||
getQueryParam :: Maybe String -> BaseUrl -> EitherT String IO Person
|
getQueryParam :: Maybe String -> BaseUrl -> EitherT String IO Person
|
||||||
|
@ -104,6 +107,7 @@ getMultiple :: String -> Maybe Int -> Bool -> [(String, [Rational])]
|
||||||
-> BaseUrl
|
-> BaseUrl
|
||||||
-> EitherT String IO (String, Maybe Int, Bool, [(String, [Rational])])
|
-> EitherT String IO (String, Maybe Int, Bool, [(String, [Rational])])
|
||||||
( getGet
|
( getGet
|
||||||
|
:<|> getDelete
|
||||||
:<|> getCapture
|
:<|> getCapture
|
||||||
:<|> getBody
|
:<|> getBody
|
||||||
:<|> getQueryParam
|
:<|> getQueryParam
|
||||||
|
@ -122,6 +126,9 @@ spec = do
|
||||||
it "Servant.API.Get" $ withServer $ \ host -> do
|
it "Servant.API.Get" $ withServer $ \ host -> do
|
||||||
runEitherT (getGet host) `shouldReturn` Right alice
|
runEitherT (getGet host) `shouldReturn` Right alice
|
||||||
|
|
||||||
|
it "Servant.API.Delete" $ withServer $ \ host -> do
|
||||||
|
runEitherT (getDelete host) `shouldReturn` Right ()
|
||||||
|
|
||||||
it "Servant.API.Capture" $ withServer $ \ host -> do
|
it "Servant.API.Capture" $ withServer $ \ host -> do
|
||||||
runEitherT (getCapture "Paula" host) `shouldReturn` Right (Person "Paula" 0)
|
runEitherT (getCapture "Paula" host) `shouldReturn` Right (Person "Paula" 0)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue