mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-16 01:44:03 +03:00
ac8f9daaa9
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/3328 GitOrigin-RevId: 5f1cfc43434d971083b32e992e40f348bbf75ecd
27 lines
649 B
Haskell
27 lines
649 B
Haskell
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)
|