mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-20 22:11:45 +03:00
a61741fbf5
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5350 GitOrigin-RevId: ae622a859af4c308daf1aacc2825657ec7f0f8ab
54 lines
1.6 KiB
Haskell
54 lines
1.6 KiB
Haskell
-- |
|
|
-- Tests to determine whether we can create tables with unique constraints.
|
|
--
|
|
-- https://hasura.io/docs/latest/guides/postgres/constraints/#unique-constraints
|
|
module Test.Postgres.UniqueConstraintsSpec (spec) where
|
|
|
|
import Harness.Backend.Citus qualified as Citus
|
|
import Harness.Backend.Postgres qualified as Postgres
|
|
import Harness.Test.Fixture qualified as Fixture
|
|
import Harness.Test.Schema (Table (..), table)
|
|
import Harness.Test.Schema qualified as Schema
|
|
import Harness.TestEnvironment (TestEnvironment)
|
|
import Hasura.Prelude
|
|
import Test.Hspec (SpecWith, describe, it)
|
|
|
|
spec :: SpecWith TestEnvironment
|
|
spec = do
|
|
Fixture.run
|
|
[ (Fixture.fixture $ Fixture.Backend Fixture.Postgres)
|
|
{ Fixture.setupTeardown = \(testEnv, _) ->
|
|
[ Postgres.setupTablesAction schema testEnv
|
|
]
|
|
},
|
|
(Fixture.fixture $ Fixture.Backend Fixture.Citus)
|
|
{ Fixture.setupTeardown = \(testEnv, _) ->
|
|
[ Citus.setupTablesAction schema testEnv
|
|
]
|
|
}
|
|
]
|
|
tests
|
|
|
|
--------------------------------------------------------------------------------
|
|
-- Schema
|
|
|
|
schema :: [Table]
|
|
schema =
|
|
[ (table "test")
|
|
{ tableColumns =
|
|
[ Schema.column "id" Schema.TInt,
|
|
Schema.column "username" Schema.TStr
|
|
],
|
|
tableUniqueConstraints =
|
|
[ Schema.UniqueConstraintExpression "lower(username)"
|
|
]
|
|
}
|
|
]
|
|
|
|
--------------------------------------------------------------------------------
|
|
-- Tests
|
|
|
|
tests :: Fixture.Options -> SpecWith TestEnvironment
|
|
tests _ = describe "Unique constraints" do
|
|
it "Creates a schema with unique constraints" \_ -> pure @IO ()
|