Add a simple test for openapi
This commit is contained in:
@@ -8,7 +8,7 @@ import SpecHelper
|
|||||||
|
|
||||||
import Network.HTTP.Types
|
import Network.HTTP.Types
|
||||||
import Network.Wai (Application)
|
import Network.Wai (Application)
|
||||||
import Network.Wai.Test (SResponse(simpleHeaders))
|
import Network.Wai.Test (SResponse(simpleStatus, simpleHeaders, simpleBody))
|
||||||
|
|
||||||
spec :: SpecWith Application
|
spec :: SpecWith Application
|
||||||
spec = do
|
spec = do
|
||||||
@@ -61,6 +61,21 @@ spec = do
|
|||||||
] |]
|
] |]
|
||||||
{matchStatus = 200}
|
{matchStatus = 200}
|
||||||
|
|
||||||
|
it "returns a valid swagger spec" $ do
|
||||||
|
r <- request methodGet "/" [("Accept", "application/openapi+json")] ""
|
||||||
|
liftIO $
|
||||||
|
let respStatus = simpleStatus r in
|
||||||
|
respStatus `shouldSatisfy`
|
||||||
|
\s -> s == Status { statusCode = 200, statusMessage="OK" }
|
||||||
|
liftIO $
|
||||||
|
let respHeaders = simpleHeaders r in
|
||||||
|
respHeaders `shouldSatisfy`
|
||||||
|
\hs -> ("Content-Type", "application/openapi+json; charset=utf-8") `elem` hs
|
||||||
|
liftIO $
|
||||||
|
let respBody = simpleBody r in
|
||||||
|
respBody `shouldSatisfy`
|
||||||
|
\b -> b == b
|
||||||
|
|
||||||
describe "Table info" $ do
|
describe "Table info" $ do
|
||||||
it "The structure of complex views is correctly detected" $
|
it "The structure of complex views is correctly detected" $
|
||||||
request methodOptions "/filtered_tasks" [] "" `shouldRespondWith`
|
request methodOptions "/filtered_tasks" [] "" `shouldRespondWith`
|
||||||
|
|||||||
Reference in New Issue
Block a user