Merge pull request #421 from ruslantalpa/spec-cache-dbstructure
Fix failing test after test structure optimization
This commit is contained in:
@@ -158,7 +158,6 @@ Test-Suite spec
|
|||||||
, PostgREST.RangeQuery
|
, PostgREST.RangeQuery
|
||||||
, PostgREST.ApiRequest
|
, PostgREST.ApiRequest
|
||||||
, PostgREST.Types
|
, PostgREST.Types
|
||||||
, Spec
|
|
||||||
, SpecHelper
|
, SpecHelper
|
||||||
, TestTypes
|
, TestTypes
|
||||||
Build-Depends: aeson
|
Build-Depends: aeson
|
||||||
|
|||||||
+11
-12
@@ -3,7 +3,7 @@ module Main where
|
|||||||
import Test.Hspec
|
import Test.Hspec
|
||||||
import SpecHelper
|
import SpecHelper
|
||||||
|
|
||||||
import PostgREST.Types (DbStructure(..))
|
--import PostgREST.Types (DbStructure(..))
|
||||||
|
|
||||||
import qualified Feature.AuthSpec
|
import qualified Feature.AuthSpec
|
||||||
import qualified Feature.CorsSpec
|
import qualified Feature.CorsSpec
|
||||||
@@ -23,16 +23,15 @@ main = do
|
|||||||
|
|
||||||
-- Not using hspec-discover because we want to precompute
|
-- Not using hspec-discover because we want to precompute
|
||||||
-- the db structure and pass it to specs for speed
|
-- the db structure and pass it to specs for speed
|
||||||
mapM_ (hspec . ($ pool) . ($ dbStructure)) specs
|
hspec $ specs dbStructure pool
|
||||||
|
|
||||||
where
|
where
|
||||||
specs = [
|
specs dbStructure pool = do
|
||||||
Feature.AuthSpec.spec
|
describe "Feature.AuthSpec" $ Feature.AuthSpec.spec dbStructure pool
|
||||||
, Feature.CorsSpec.spec
|
describe "Feature.CorsSpec" $ Feature.CorsSpec.spec dbStructure pool
|
||||||
, Feature.DeleteSpec.spec
|
describe "Feature.DeleteSpec" $ Feature.DeleteSpec.spec dbStructure pool
|
||||||
, Feature.InsertSpec.spec
|
describe "Feature.InsertSpec" $ Feature.InsertSpec.spec dbStructure pool
|
||||||
, Feature.QueryLimitedSpec.spec
|
describe "Feature.QueryLimitedSpec" $ Feature.QueryLimitedSpec.spec dbStructure pool
|
||||||
, Feature.QuerySpec.spec
|
describe "Feature.QuerySpec" $ Feature.QuerySpec.spec dbStructure pool
|
||||||
, Feature.RangeSpec.spec
|
describe "Feature.RangeSpec" $ Feature.RangeSpec.spec dbStructure pool
|
||||||
, Feature.StructureSpec.spec
|
describe "Feature.StructureSpec" $ Feature.StructureSpec.spec dbStructure pool
|
||||||
]
|
|
||||||
|
|||||||
+2
-1
@@ -56,7 +56,7 @@ specDbPool = H.acquirePool pgSettings testPoolOpts
|
|||||||
specDbStructure :: H.Pool P.Postgres -> IO DbStructure
|
specDbStructure :: H.Pool P.Postgres -> IO DbStructure
|
||||||
specDbStructure pool = do
|
specDbStructure pool = do
|
||||||
dbOrError <- H.session pool $ H.tx specTxSettings
|
dbOrError <- H.session pool $ H.tx specTxSettings
|
||||||
$ getDbStructure "postgrest_test"
|
$ getDbStructure "test"
|
||||||
either (fail . show) return dbOrError
|
either (fail . show) return dbOrError
|
||||||
|
|
||||||
withApp :: AppConfig -> DbStructure -> H.Pool P.Postgres
|
withApp :: AppConfig -> DbStructure -> H.Pool P.Postgres
|
||||||
@@ -116,4 +116,5 @@ clearTable table = do
|
|||||||
void . liftIO $ H.session pool $ H.tx Nothing $
|
void . liftIO $ H.session pool $ H.tx Nothing $
|
||||||
H.unitEx $ B.Stmt ("truncate table test." <> table <> " cascade") V.empty True
|
H.unitEx $ B.Stmt ("truncate table test." <> table <> " cascade") V.empty True
|
||||||
|
|
||||||
|
specTxSettings :: Maybe (TxIsolationLevel, Maybe Bool)
|
||||||
specTxSettings = Just (H.ReadCommitted, Just True)
|
specTxSettings = Just (H.ReadCommitted, Just True)
|
||||||
|
|||||||
Reference in New Issue
Block a user