mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-17 12:31:52 +03:00
b658df1c43
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
53 lines
1.4 KiB
Haskell
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)"]
|
|
}
|
|
]
|