Upgrade hspec-wai dependency to 0.10.

This commit is contained in:
Robert Vollmert
2020-03-07 13:04:17 -05:00
committed by Steve Chavez
parent 962fba4d16
commit 60b64d3e81
33 changed files with 69 additions and 51 deletions
+1 -1
View File
@@ -11,7 +11,7 @@ import PostgREST.Types (PgVersion, pgVersion112)
import Protolude hiding (get)
import SpecHelper
spec :: PgVersion -> SpecWith Application
spec :: PgVersion -> SpecWith ((), Application)
spec actualPgVersion =
describe "and/or params used for complex boolean logic" $ do
context "used with GET" $ do
+1 -1
View File
@@ -11,7 +11,7 @@ import Protolude
import SpecHelper
-- }}}
spec :: SpecWith Application
spec :: SpecWith ((), Application)
spec = describe "server started with asymmetric JWK" $
-- this test will stop working 9999999999s after the UNIX EPOCH
+1 -1
View File
@@ -11,7 +11,7 @@ import Protolude hiding (get)
import SpecHelper
-- }}}
spec :: SpecWith Application
spec :: SpecWith ((), Application)
spec = describe "test handling of aud claims in JWT" $ do
-- this test will stop working 9999999999s after the UNIX EPOCH
+1 -1
View File
@@ -12,7 +12,7 @@ import PostgREST.Types (PgVersion, pgVersion112)
import Protolude hiding (get)
import SpecHelper
spec :: PgVersion -> SpecWith Application
spec :: PgVersion -> SpecWith ((), Application)
spec actualPgVersion = describe "authorization" $ do
let single = ("Accept","application/vnd.pgrst.object+json")
+1 -1
View File
@@ -11,7 +11,7 @@ import Protolude
import SpecHelper
-- }}}
spec :: SpecWith Application
spec :: SpecWith ((), Application)
spec = describe "server started with binary JWT secret" $
-- this test will stop working 9999999999s after the UNIX EPOCH
+5 -5
View File
@@ -19,7 +19,7 @@ import Test.Hspec.Wai.JSON
import Protolude hiding (get)
spec :: SpecWith Application
spec :: SpecWith ((), Application)
spec =
describe "Queryiny in parallel" $
it "should not raise 'transaction in progress' error" $
@@ -35,13 +35,13 @@ spec =
, matchHeaders = []
}
raceTest :: Int -> WaiExpectation -> WaiExpectation
raceTest :: Int -> WaiExpectation st -> WaiExpectation st
raceTest times = liftBaseDiscard go
where
go test = void $ mapConcurrently (const test) [1..times]
instance MonadBaseControl IO WaiSession where
type StM WaiSession a = StM Session a
instance MonadBaseControl IO (WaiSession st) where
type StM (WaiSession st) a = StM Session a
liftBaseWith f = WaiSession $
liftBaseWith $ \runInBase ->
f $ \k -> runInBase (unWaiSession k)
@@ -49,5 +49,5 @@ instance MonadBaseControl IO WaiSession where
{-# INLINE liftBaseWith #-}
{-# INLINE restoreM #-}
instance MonadBase IO WaiSession where
instance MonadBase IO (WaiSession st) where
liftBase = liftIO
+1 -1
View File
@@ -14,7 +14,7 @@ import Protolude
import SpecHelper
-- }}}
spec :: SpecWith Application
spec :: SpecWith ((), Application)
spec =
describe "CORS" $ do
let preflightHeaders = [
+1 -1
View File
@@ -10,7 +10,7 @@ import Text.Heredoc
import Protolude hiding (get)
spec :: SpecWith Application
spec :: SpecWith ((), Application)
spec =
describe "Deleting" $ do
context "existing record" $ do
+1 -1
View File
@@ -10,7 +10,7 @@ import Text.Heredoc
import Protolude hiding (get)
import SpecHelper
spec :: SpecWith Application
spec :: SpecWith ((), Application)
spec =
describe "resource embedding disambiguation" $ do
context "ambiguous requests that give 300 Multiple Choices" $ do
+1 -1
View File
@@ -9,7 +9,7 @@ import Test.Hspec.Wai.JSON
import Protolude
import SpecHelper
spec :: SpecWith Application
spec :: SpecWith ((), Application)
spec = describe "extra search path" $ do
it "finds the ltree <@ operator on the public schema" $
+1 -1
View File
@@ -10,7 +10,7 @@ import Text.Heredoc
import Protolude hiding (get)
import SpecHelper (acceptHdrs)
spec :: SpecWith Application
spec :: SpecWith ((), Application)
spec = describe "When raw-media-types is set to \"text/html\"" $
it "can get raw output with Accept: text/html" $
request methodGet "/rpc/welcome.html" (acceptHdrs "text/html") ""
+1 -1
View File
@@ -20,7 +20,7 @@ import PostgREST.Types (PgVersion, pgVersion112)
import Protolude hiding (get)
import SpecHelper
spec :: PgVersion -> SpecWith Application
spec :: PgVersion -> SpecWith ((), Application)
spec actualPgVersion = do
describe "Posting new record" $ do
context "disparate json types" $ do
+1 -1
View File
@@ -11,7 +11,7 @@ import PostgREST.Types (PgVersion, pgVersion112)
import Protolude hiding (get)
import SpecHelper
spec :: PgVersion -> SpecWith Application
spec :: PgVersion -> SpecWith ((), Application)
spec actualPgVersion = describe "json and jsonb operators" $ do
context "Shaping response with select parameter" $ do
it "obtains a json subfield one level with casting" $
+1 -1
View File
@@ -13,7 +13,7 @@ import Protolude
import SpecHelper
-- }}}
spec :: SpecWith Application
spec :: SpecWith ((), Application)
spec = describe "server started without JWT secret" $ do
-- this test will stop working 9999999999s after the UNIX EPOCH
+1 -1
View File
@@ -7,7 +7,7 @@ import Test.Hspec.Wai
import Protolude hiding (get)
spec :: SpecWith Application
spec :: SpecWith ((), Application)
spec =
describe "Non existent api schema" $ do
it "succeeds when requesting root path" $
+1 -1
View File
@@ -9,7 +9,7 @@ import Test.Hspec.Wai.JSON
import Protolude hiding (get)
import SpecHelper
spec :: SpecWith Application
spec :: SpecWith ((), Application)
spec = describe "features supported on PostgreSQL 9.5" $
context "json array negative index" $ do
it "can select with negative indexes" $ do
+1 -1
View File
@@ -10,7 +10,7 @@ import Test.Hspec.Wai.JSON
import Protolude hiding (get)
import SpecHelper
spec :: SpecWith Application
spec :: SpecWith ((), Application)
spec =
describe "features supported on PostgreSQL 9.6" $ do
context "GUC headers on function calls" $ do
+1 -1
View File
@@ -6,7 +6,7 @@ import Test.Hspec hiding (pendingWith)
import Protolude
import SpecHelper
spec :: SpecWith Application
spec :: SpecWith ((), Application)
spec =
describe "GET / with proxy" $
it "returns a valid openapi spec with proxy" $
+1 -1
View File
@@ -11,7 +11,7 @@ import Test.Hspec.Wai.JSON
import Protolude hiding (get)
import SpecHelper
spec :: SpecWith Application
spec :: SpecWith ((), Application)
spec =
describe "Requesting many items with server limits(max-rows) enabled" $ do
it "restricts results" $
+1 -1
View File
@@ -14,7 +14,7 @@ import PostgREST.Types (PgVersion, pgVersion112)
import Protolude hiding (get)
import SpecHelper
spec :: PgVersion -> SpecWith Application
spec :: PgVersion -> SpecWith ((), Application)
spec actualPgVersion = do
describe "Querying a table with a column called count" $
+1 -1
View File
@@ -19,7 +19,7 @@ defaultRange = [json| { "min": 0, "max": 15 } |]
emptyRange :: BL.ByteString
emptyRange = [json| { "min": 2, "max": 2 } |]
spec :: SpecWith Application
spec :: SpecWith ((), Application)
spec = do
describe "POST /rpc/getitemrange" $ do
context "without range headers" $ do
+1 -1
View File
@@ -10,7 +10,7 @@ import Test.Hspec.Wai.JSON
import Protolude
import SpecHelper (acceptHdrs)
spec :: SpecWith Application
spec :: SpecWith ((), Application)
spec = describe "When raw-media-types config variable is missing or left empty" $ do
let firefoxAcceptHdrs = acceptHdrs "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
chromeAcceptHdrs = acceptHdrs "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3"
+1 -1
View File
@@ -11,7 +11,7 @@ import Protolude hiding (get)
import SpecHelper
spec :: SpecWith Application
spec :: SpecWith ((), Application)
spec =
describe "root spec function" $ do
it "accepts application/openapi+json" $
+1 -1
View File
@@ -17,7 +17,7 @@ import PostgREST.Types (PgVersion, pgVersion100, pgVersion109,
import Protolude hiding (get)
import SpecHelper
spec :: PgVersion -> SpecWith Application
spec :: PgVersion -> SpecWith ((), Application)
spec actualPgVersion =
describe "remote procedure call" $ do
context "a proc that returns a set" $ do
+1 -1
View File
@@ -13,7 +13,7 @@ import Protolude hiding (get)
import SpecHelper
spec :: SpecWith Application
spec :: SpecWith ((), Application)
spec =
describe "Requesting singular json object" $ do
let pgrstObj = "application/vnd.pgrst.object+json"
+1 -1
View File
@@ -17,7 +17,7 @@ import PostgREST.Config (docsVersion)
import Protolude hiding (get)
import SpecHelper
spec :: SpecWith Application
spec :: SpecWith ((), Application)
spec = do
describe "OpenAPI" $ do
+1 -1
View File
@@ -10,7 +10,7 @@ import Test.Hspec.Wai.JSON
import Protolude hiding (get)
import SpecHelper
spec :: SpecWith Application
spec :: SpecWith ((), Application)
spec =
describe "Reading and writing to unicode schema and table names" $
it "Can read and write values" $ do
+1 -1
View File
@@ -11,7 +11,7 @@ import Text.Heredoc
import Protolude hiding (get, put)
import SpecHelper
spec :: SpecWith Application
spec :: SpecWith ((), Application)
spec =
describe "UPSERT" $ do
context "with POST" $ do
+16 -14
View File
@@ -65,20 +65,22 @@ main = do
refDbStructure <- newIORef $ Just dbStructure
let withApp = return $ postgrest (testCfg testDbConn) refDbStructure pool getTime $ pure ()
maxRowsApp = return $ postgrest (testMaxRowsCfg testDbConn) refDbStructure pool getTime $ pure ()
unicodeApp = return $ postgrest (testUnicodeCfg testDbConn) refDbStructure pool getTime $ pure ()
proxyApp = return $ postgrest (testProxyCfg testDbConn) refDbStructure pool getTime $ pure ()
noJwtApp = return $ postgrest (testCfgNoJWT testDbConn) refDbStructure pool getTime $ pure ()
binaryJwtApp = return $ postgrest (testCfgBinaryJWT testDbConn) refDbStructure pool getTime $ pure ()
audJwtApp = return $ postgrest (testCfgAudienceJWT testDbConn) refDbStructure pool getTime $ pure ()
asymJwkApp = return $ postgrest (testCfgAsymJWK testDbConn) refDbStructure pool getTime $ pure ()
asymJwkSetApp = return $ postgrest (testCfgAsymJWKSet testDbConn) refDbStructure pool getTime $ pure ()
nonexistentSchemaApp = return $ postgrest (testNonexistentSchemaCfg testDbConn) refDbStructure pool getTime $ pure ()
extraSearchPathApp = return $ postgrest (testCfgExtraSearchPath testDbConn) refDbStructure pool getTime $ pure ()
rootSpecApp = return $ postgrest (testCfgRootSpec testDbConn) refDbStructure pool getTime $ pure ()
htmlRawOutputApp = return $ postgrest (testCfgHtmlRawOutput testDbConn) refDbStructure pool getTime $ pure ()
responseHeadersApp = return $ postgrest (testCfgResponseHeaders testDbConn) refDbStructure pool getTime $ pure ()
let app cfg = return ((), postgrest (cfg testDbConn) refDbStructure pool getTime $ pure ())
let withApp = app testCfg
maxRowsApp = app testMaxRowsCfg
unicodeApp = app testUnicodeCfg
proxyApp = app testProxyCfg
noJwtApp = app testCfgNoJWT
binaryJwtApp = app testCfgBinaryJWT
audJwtApp = app testCfgAudienceJWT
asymJwkApp = app testCfgAsymJWK
asymJwkSetApp = app testCfgAsymJWKSet
nonexistentSchemaApp = app testNonexistentSchemaCfg
extraSearchPathApp = app testCfgExtraSearchPath
rootSpecApp = app testCfgRootSpec
htmlRawOutputApp = app testCfgHtmlRawOutput
responseHeadersApp = app testCfgResponseHeaders
let reset, analyze :: IO ()
reset = resetDb testDbConn
+1 -1
View File
@@ -32,7 +32,7 @@ matchContentTypeJson = "Content-Type" <:> "application/json; charset=utf-8"
matchContentTypeSingular :: MatchHeader
matchContentTypeSingular = "Content-Type" <:> "application/vnd.pgrst.object+json; charset=utf-8"
validateOpenApiResponse :: [Header] -> WaiSession ()
validateOpenApiResponse :: [Header] -> WaiSession () ()
validateOpenApiResponse headers = do
r <- request methodGet "/" headers ""
liftIO $