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))
|
2022-08-11 18:03:04 +03:00
|
|
|
import Data.List.NonEmpty qualified as NE
|
2022-08-04 17:33:05 +03:00
|
|
|
import Harness.Backend.Postgres qualified as Postgres
|
2022-08-05 12:34:25 +03:00
|
|
|
import Harness.Quoter.Yaml (yaml)
|
2022-08-04 17:33:05 +03:00
|
|
|
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-05 12:34:25 +03:00
|
|
|
import Harness.Yaml (shouldReturnYaml)
|
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
|
2022-08-11 18:03:04 +03:00
|
|
|
( (Fixture.fixture $ Fixture.Backend Fixture.Postgres)
|
2022-08-04 17:33:05 +03:00
|
|
|
{ Fixture.setupTeardown = \(testEnvironment, _) ->
|
|
|
|
[ Postgres.setupTablesAction schema testEnvironment
|
|
|
|
]
|
|
|
|
}
|
2022-08-11 18:03:04 +03:00
|
|
|
NE.:| []
|
|
|
|
)
|
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
|