Add test for emptyAPIServer
This commit is contained in:
parent
fa3f1869f2
commit
937a5c98fd
1 changed files with 7 additions and 2 deletions
|
@ -42,14 +42,14 @@ import Servant.API ((:<|>) (..), (:>), AuthProtect,
|
||||||
Headers, HttpVersion,
|
Headers, HttpVersion,
|
||||||
IsSecure (..), JSON,
|
IsSecure (..), JSON,
|
||||||
NoContent (..), Patch, PlainText,
|
NoContent (..), Patch, PlainText,
|
||||||
Post, Put,
|
Post, Put, EmptyAPI,
|
||||||
QueryFlag, QueryParam, QueryParams,
|
QueryFlag, QueryParam, QueryParams,
|
||||||
Raw, RemoteHost, ReqBody,
|
Raw, RemoteHost, ReqBody,
|
||||||
StdMethod (..), Verb, addHeader)
|
StdMethod (..), Verb, addHeader)
|
||||||
import Servant.API.Internal.Test.ComprehensiveAPI
|
import Servant.API.Internal.Test.ComprehensiveAPI
|
||||||
import Servant.Server (Server, Handler, Tagged (..), err401, err403,
|
import Servant.Server (Server, Handler, Tagged (..), err401, err403,
|
||||||
err404, serve, serveWithContext,
|
err404, serve, serveWithContext,
|
||||||
Context((:.), EmptyContext))
|
Context((:.), EmptyContext), emptyAPIServer)
|
||||||
import Test.Hspec (Spec, context, describe, it,
|
import Test.Hspec (Spec, context, describe, it,
|
||||||
shouldBe, shouldContain)
|
shouldBe, shouldContain)
|
||||||
import qualified Test.Hspec.Wai as THW
|
import qualified Test.Hspec.Wai as THW
|
||||||
|
@ -609,6 +609,7 @@ type MiscCombinatorsAPI
|
||||||
= "version" :> HttpVersion :> Get '[JSON] String
|
= "version" :> HttpVersion :> Get '[JSON] String
|
||||||
:<|> "secure" :> IsSecure :> Get '[JSON] String
|
:<|> "secure" :> IsSecure :> Get '[JSON] String
|
||||||
:<|> "host" :> RemoteHost :> Get '[JSON] String
|
:<|> "host" :> RemoteHost :> Get '[JSON] String
|
||||||
|
:<|> "empty" :> EmptyAPI
|
||||||
|
|
||||||
miscApi :: Proxy MiscCombinatorsAPI
|
miscApi :: Proxy MiscCombinatorsAPI
|
||||||
miscApi = Proxy
|
miscApi = Proxy
|
||||||
|
@ -617,6 +618,7 @@ miscServ :: Server MiscCombinatorsAPI
|
||||||
miscServ = versionHandler
|
miscServ = versionHandler
|
||||||
:<|> secureHandler
|
:<|> secureHandler
|
||||||
:<|> hostHandler
|
:<|> hostHandler
|
||||||
|
:<|> emptyAPIServer
|
||||||
|
|
||||||
where versionHandler = return . show
|
where versionHandler = return . show
|
||||||
secureHandler Secure = return "secure"
|
secureHandler Secure = return "secure"
|
||||||
|
@ -635,6 +637,9 @@ miscCombinatorSpec = with (return $ serve miscApi miscServ) $
|
||||||
it "Checks that hspec-wai issues request from 0.0.0.0" $
|
it "Checks that hspec-wai issues request from 0.0.0.0" $
|
||||||
go "/host" "\"0.0.0.0:0\""
|
go "/host" "\"0.0.0.0:0\""
|
||||||
|
|
||||||
|
it "Doesn't serve anything from the empty API" $
|
||||||
|
Test.Hspec.Wai.get "empty" `shouldRespondWith` 404
|
||||||
|
|
||||||
where go path res = Test.Hspec.Wai.get path `shouldRespondWith` res
|
where go path res = Test.Hspec.Wai.get path `shouldRespondWith` res
|
||||||
|
|
||||||
-- }}}
|
-- }}}
|
||||||
|
|
Loading…
Reference in a new issue