From 937a5c98fd5a999760684791e761c15149e2ed7a Mon Sep 17 00:00:00 2001 From: David Turner Date: Tue, 16 May 2017 10:18:57 +0000 Subject: [PATCH] Add test for emptyAPIServer --- servant-server/test/Servant/ServerSpec.hs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/servant-server/test/Servant/ServerSpec.hs b/servant-server/test/Servant/ServerSpec.hs index 3db3e27c..fbcd1929 100644 --- a/servant-server/test/Servant/ServerSpec.hs +++ b/servant-server/test/Servant/ServerSpec.hs @@ -42,14 +42,14 @@ import Servant.API ((:<|>) (..), (:>), AuthProtect, Headers, HttpVersion, IsSecure (..), JSON, NoContent (..), Patch, PlainText, - Post, Put, + Post, Put, EmptyAPI, QueryFlag, QueryParam, QueryParams, Raw, RemoteHost, ReqBody, StdMethod (..), Verb, addHeader) import Servant.API.Internal.Test.ComprehensiveAPI import Servant.Server (Server, Handler, Tagged (..), err401, err403, err404, serve, serveWithContext, - Context((:.), EmptyContext)) + Context((:.), EmptyContext), emptyAPIServer) import Test.Hspec (Spec, context, describe, it, shouldBe, shouldContain) import qualified Test.Hspec.Wai as THW @@ -609,6 +609,7 @@ type MiscCombinatorsAPI = "version" :> HttpVersion :> Get '[JSON] String :<|> "secure" :> IsSecure :> Get '[JSON] String :<|> "host" :> RemoteHost :> Get '[JSON] String + :<|> "empty" :> EmptyAPI miscApi :: Proxy MiscCombinatorsAPI miscApi = Proxy @@ -617,6 +618,7 @@ miscServ :: Server MiscCombinatorsAPI miscServ = versionHandler :<|> secureHandler :<|> hostHandler + :<|> emptyAPIServer where versionHandler = return . show 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" $ 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 -- }}}