graphql-engine/server/tests-hspec/Test/GatheringUniqueConstraintsSpec.hs
Philip Lykke Carlsen b658df1c43 Spike attempt at adding logging to the hspec test-suite
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4772
Co-authored-by: Gil Mizrahi <8547573+soupi@users.noreply.github.com>
GitOrigin-RevId: 5c6c9056952574462d5b309774331a909a7eac6d
2022-08-03 14:19:53 +00:00

53 lines
1.4 KiB
Haskell

-- | This module tests that the postgres table metadata collection correctly
-- handles unique constraints that are based on expressions rather than columns.
module Test.GatheringUniqueConstraintsSpec (spec) where
import Harness.Backend.Citus qualified as Citus
import Harness.Backend.Postgres qualified as Postgres
import Harness.Test.BackendType qualified as BackendType
import Harness.Test.Fixture
import Harness.Test.Schema
import Harness.TestEnvironment (TestEnvironment (..))
import Hasura.Prelude
import Test.Hspec
--------------------------------------------------------------------------------
-- Preamble
spec :: SpecWith TestEnvironment
spec =
run
[postgresFixture, citusFixture]
(\_ -> it "Tracks tables without failing" \_ -> return @IO ())
postgresFixture :: Fixture ()
postgresFixture =
(fixture $ Backend BackendType.Postgres)
{ setupTeardown = \(t, _) ->
[ Postgres.setupTablesAction tables t
]
}
citusFixture :: Fixture ()
citusFixture =
(fixture $ Backend BackendType.Citus)
{ setupTeardown = \(t, _) ->
[ Citus.setupTablesAction tables t
]
}
{-
CREATE TABLE test (id INT, username TEXT);
CREATE UNIQUE INDEX ON test ((lower(username)));
-}
tables :: [Table]
tables =
[ (table "test")
{ tableColumns =
[ column "id" TInt,
column "username" TStr
],
tableUniqueConstraints = [UniqueConstraintExpression "lower(username)"]
}
]