Use hspec-discover for hspec-tests

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3328
GitOrigin-RevId: 5f1cfc43434d971083b32e992e40f348bbf75ecd
This commit is contained in:
Gil Mizrahi 2022-01-13 23:13:48 +02:00 committed by hasura-bot
parent 560daa63a8
commit ac8f9daaa9
4 changed files with 41 additions and 55 deletions

View File

@ -172,9 +172,9 @@ constraints: any.Cabal ==3.2.0.0,
any.hpc ==0.6.1.0,
any.hsc2hs ==0.68.7,
hsc2hs -in-ghc-tree,
any.hspec ==2.8.2,
any.hspec-core ==2.8.2,
any.hspec-discover ==2.8.2,
any.hspec ==2.8.3,
any.hspec-core ==2.8.3,
any.hspec-discover ==2.8.3,
any.hspec-expectations ==0.8.2,
any.hspec-expectations-lifted ==0.10.0,
any.hspec-hedgehog ==0.0.1.2,

View File

@ -755,9 +755,9 @@ test-suite graphql-engine-integration-tests
, ekg-core
, exceptions
, hedgehog
, hspec >=2.6.1 && <3
, hspec-core >=2.6.1 && <3
, hspec-discover
, hspec >=2.8.3 && <3
, hspec-core >=2.8.3 && <3
, hspec-discover >=2.8.3 && <3
, hspec-expectations
, hspec-wai
, hspec-wai-json
@ -800,8 +800,8 @@ test-suite graphql-engine-tests
, graphql-engine
, graphql-parser
, hedgehog
, hspec >=2.6.1 && <3
, hspec-core >=2.6.1 && <3
, hspec >=2.8.3 && <3
, hspec-core >=2.8.3 && <3
, hspec-expectations
, hspec-expectations-lifted
, hspec-hedgehog
@ -875,6 +875,7 @@ test-suite graphql-engine-tests
test-suite tests-hspec
import: common-all, common-exe
type: exitcode-stdio-1.0
build-tool-depends: hspec-discover:hspec-discover
build-depends:
aeson
, base
@ -888,8 +889,9 @@ test-suite tests-hspec
, graphql-parser
, haskell-src-meta
, hedgehog
, hspec >=2.6.1 && <3
, hspec-core >=2.6.1 && <3
, hspec >=2.8.3 && <3
, hspec-core >=2.8.3 && <3
, hspec-discover >=2.8.3 && <3
, hspec-expectations
, hspec-expectations-lifted
, hspec-hedgehog
@ -956,6 +958,7 @@ test-suite tests-hspec
ghc-options: -Wall -O0 -threaded
main-is: Spec.hs
other-modules:
SpecHook
Harness.Mysql
Harness.Http
Harness.Postgres

View File

@ -1,45 +1,2 @@
module Main (main) where
import ArrayRelationshipsSpec qualified
import BasicFieldsSpec qualified
import Control.Exception
import DirectivesSpec qualified
import Harness.GraphqlEngine (startServerThread, stopServer)
import Harness.State (State (..))
import LimitOffsetSpec qualified
import NestedRelationshipsSpec qualified
import ObjectRelationshipsSpec qualified
import OrderingSpec qualified
import ServiceLivenessSpec qualified
import System.Environment
import Test.Hspec
import Text.Read
import ViewsSpec qualified
import WhereSpec qualified
import Prelude
setupState :: IO State
setupState = do
murlPrefix <- lookupEnv "HASURA_TEST_URLPREFIX"
mport <- fmap (>>= readMaybe) (lookupEnv "HASURA_TEST_PORT")
server <- startServerThread ((,) <$> murlPrefix <*> mport)
pure State {server}
teardownState :: State -> IO ()
teardownState State {server} =
stopServer server
main :: IO ()
main =
hspec $
aroundAllWith (const . bracket setupState teardownState) $ do
describe "ServiceLiveness" ServiceLivenessSpec.spec
describe "BasicFields" BasicFieldsSpec.spec
describe "Ordering" OrderingSpec.spec
describe "Where" WhereSpec.spec
describe "LimitOffset" LimitOffsetSpec.spec
describe "ObjectRelationships" ObjectRelationshipsSpec.spec
describe "ArrayRelationships" ArrayRelationshipsSpec.spec
describe "Directives" DirectivesSpec.spec
describe "Views" ViewsSpec.spec
describe "NestedRelationships" NestedRelationshipsSpec.spec
{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
{-# OPTIONS_GHC -Wno-missing-export-lists #-}

View File

@ -0,0 +1,26 @@
module SpecHook
( hook,
)
where
import Control.Exception
import Harness.GraphqlEngine (startServerThread, stopServer)
import Harness.State (State (..))
import System.Environment
import Test.Hspec
import Text.Read
import Prelude
setupState :: IO State
setupState = do
murlPrefix <- lookupEnv "HASURA_TEST_URLPREFIX"
mport <- fmap (>>= readMaybe) (lookupEnv "HASURA_TEST_PORT")
server <- startServerThread ((,) <$> murlPrefix <*> mport)
pure State {server}
teardownState :: State -> IO ()
teardownState State {server} =
stopServer server
hook :: SpecWith State -> Spec
hook = aroundAllWith (const . bracket setupState teardownState)