mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-24 07:52:14 +03:00
0922a3bb24
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5451 GitOrigin-RevId: 8847af09a83293c619326d22209289397911bc5a
62 lines
1.7 KiB
Haskell
62 lines
1.7 KiB
Haskell
{-# LANGUAGE QuasiQuotes #-}
|
|
|
|
-- | A starting point feature test.
|
|
module Test.HelloWorldSpec (spec) where
|
|
|
|
import Data.Aeson (Value (Null))
|
|
import Data.List.NonEmpty qualified as NE
|
|
import Harness.Backend.Postgres qualified as Postgres
|
|
import Harness.Quoter.Yaml (yaml)
|
|
import Harness.Test.Fixture qualified as Fixture
|
|
import Harness.Test.Schema qualified as Schema
|
|
import Harness.TestEnvironment (TestEnvironment (..))
|
|
import Harness.Yaml (shouldReturnYaml)
|
|
import Hasura.Prelude
|
|
import Test.Hspec (SpecWith, describe, it)
|
|
|
|
spec :: SpecWith TestEnvironment
|
|
spec =
|
|
Fixture.run
|
|
( (Fixture.fixture $ Fixture.Backend Fixture.Postgres)
|
|
{ Fixture.setupTeardown = \(testEnvironment, _) ->
|
|
[ Postgres.setupTablesAction schema testEnvironment
|
|
]
|
|
}
|
|
NE.:| []
|
|
)
|
|
tests
|
|
|
|
--------------------------------------------------------------------------------
|
|
-- Schema
|
|
|
|
schema :: [Schema.Table]
|
|
schema =
|
|
[ (Schema.table "example")
|
|
{ Schema.tableColumns =
|
|
[ Schema.column "id" Schema.TInt,
|
|
Schema.column "name" Schema.TStr
|
|
],
|
|
Schema.tablePrimaryKey = ["id"],
|
|
Schema.tableData = []
|
|
}
|
|
]
|
|
|
|
--------------------------------------------------------------------------------
|
|
-- Tests
|
|
|
|
tests :: Fixture.Options -> SpecWith TestEnvironment
|
|
tests opts = do
|
|
let shouldBe :: IO Value -> Value -> IO ()
|
|
shouldBe = shouldReturnYaml opts
|
|
|
|
describe "Example test" do
|
|
it "Works as expected" \testEnvironment -> do
|
|
let expected :: Value
|
|
expected = [yaml| null |]
|
|
|
|
actual :: IO Value
|
|
actual = pure Null
|
|
|
|
logger testEnvironment "A log message\n"
|
|
actual `shouldBe` expected
|