2022-08-04 17:33:05 +03:00
|
|
|
{-# LANGUAGE QuasiQuotes #-}
|
|
|
|
|
2022-08-03 17:18:43 +03:00
|
|
|
-- | A starting point feature test.
|
|
|
|
module Test.HelloWorldSpec (spec) where
|
|
|
|
|
2022-08-04 17:33:05 +03:00
|
|
|
import Data.Aeson (Value (Null))
|
|
|
|
import Harness.Backend.Postgres qualified as Postgres
|
|
|
|
import Harness.Quoter.Yaml (shouldReturnYaml, yaml)
|
|
|
|
import Harness.Test.Fixture qualified as Fixture
|
|
|
|
import Harness.Test.Schema qualified as Schema
|
2022-08-03 17:18:43 +03:00
|
|
|
import Harness.TestEnvironment (TestEnvironment (..))
|
2022-08-04 17:33:05 +03:00
|
|
|
import Hasura.Prelude
|
|
|
|
import Test.Hspec (SpecWith, describe, it)
|
2022-08-03 17:18:43 +03:00
|
|
|
|
|
|
|
spec :: SpecWith TestEnvironment
|
|
|
|
spec =
|
2022-08-04 17:33:05 +03:00
|
|
|
Fixture.run
|
|
|
|
[ (Fixture.fixture $ Fixture.Backend Fixture.Postgres)
|
|
|
|
{ Fixture.setupTeardown = \(testEnvironment, _) ->
|
|
|
|
[ Postgres.setupTablesAction schema testEnvironment
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
2022-08-03 17:18:43 +03:00
|
|
|
tests
|
|
|
|
|
2022-08-04 17:33:05 +03:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
-- 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 = []
|
|
|
|
}
|
|
|
|
]
|
|
|
|
|
2022-08-03 17:18:43 +03:00
|
|
|
--------------------------------------------------------------------------------
|
|
|
|
-- Tests
|
|
|
|
|
2022-08-04 17:33:05 +03:00
|
|
|
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
|