mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 17:02:49 +03:00
server/tests: Avoid schema aliasing
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6942 GitOrigin-RevId: d439290ae60f8f4be616c9217d03137cace675a6
This commit is contained in:
parent
4683d4786d
commit
cdb62ff277
@ -1,15 +1,13 @@
|
|||||||
-- | Testing regression reported at https://github.com/hasura/graphql-engine/issues/8643
|
-- | Testing regression reported at https://github.com/hasura/graphql-engine/issues/8643
|
||||||
module Test.Regression.UsingTheSameFunctionForRootFieldAndComputedField8643Spec (spec) where
|
module Test.Regression.UsingTheSameFunctionForRootFieldAndComputedField8643Spec (spec) where
|
||||||
|
|
||||||
-- import Data.Aeson (Value (Null))
|
|
||||||
import Data.List.NonEmpty qualified as NE
|
import Data.List.NonEmpty qualified as NE
|
||||||
|
import Data.Text qualified as T
|
||||||
import Harness.Backend.Postgres qualified as Postgres
|
import Harness.Backend.Postgres qualified as Postgres
|
||||||
import Harness.Constants qualified as Constants
|
|
||||||
-- import Harness.Quoter.Yaml (yaml)
|
|
||||||
import Harness.Test.Fixture qualified as Fixture
|
import Harness.Test.Fixture qualified as Fixture
|
||||||
|
import Harness.Test.Schema
|
||||||
import Harness.Test.Schema qualified as Schema
|
import Harness.Test.Schema qualified as Schema
|
||||||
import Harness.TestEnvironment (TestEnvironment (..))
|
import Harness.TestEnvironment (TestEnvironment (..))
|
||||||
-- import Harness.Yaml (shouldReturnYaml)
|
|
||||||
import Hasura.Prelude
|
import Hasura.Prelude
|
||||||
import Test.Hspec
|
import Test.Hspec
|
||||||
|
|
||||||
@ -54,20 +52,25 @@ schema =
|
|||||||
|
|
||||||
functionSetup :: TestEnvironment -> Fixture.SetupAction
|
functionSetup :: TestEnvironment -> Fixture.SetupAction
|
||||||
functionSetup testEnvironment =
|
functionSetup testEnvironment =
|
||||||
Fixture.SetupAction
|
let schemaName = T.unpack $ unSchemaName (getSchemaName testEnvironment)
|
||||||
{ setupAction =
|
in Fixture.SetupAction
|
||||||
Postgres.run_ testEnvironment $
|
{ setupAction =
|
||||||
"CREATE FUNCTION "
|
Postgres.run_ testEnvironment $
|
||||||
++ Constants.postgresDb
|
"CREATE FUNCTION "
|
||||||
++ ".authors(author_row author) \
|
++ schemaName
|
||||||
\RETURNS SETOF author AS $$ \
|
++ ".authors(author_row "
|
||||||
\ SELECT * \
|
++ schemaName
|
||||||
\ FROM "
|
++ ".author) \
|
||||||
++ Constants.postgresDb
|
\RETURNS SETOF "
|
||||||
++ ".author \
|
++ schemaName
|
||||||
\$$ LANGUAGE sql STABLE;",
|
++ ".author AS $$ \
|
||||||
teardownAction = \_ -> Postgres.run_ testEnvironment $ "DROP FUNCTION " ++ Constants.postgresDb ++ ".authors;"
|
\ SELECT * \
|
||||||
}
|
\ FROM "
|
||||||
|
++ schemaName
|
||||||
|
++ ".author \
|
||||||
|
\$$ LANGUAGE sql STABLE;",
|
||||||
|
teardownAction = \_ -> Postgres.run_ testEnvironment $ "DROP FUNCTION " ++ schemaName ++ ".authors;"
|
||||||
|
}
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- Tests
|
-- Tests
|
||||||
@ -76,6 +79,7 @@ tests :: Fixture.Options -> SpecWith TestEnvironment
|
|||||||
tests _opts = do
|
tests _opts = do
|
||||||
describe "Tracking the same function as a root field and as a computed field" do
|
describe "Tracking the same function as a root field and as a computed field" do
|
||||||
it "Does not give rise to metadata inconsistencies" \testEnvironment -> do
|
it "Does not give rise to metadata inconsistencies" \testEnvironment -> do
|
||||||
|
let schemaName = T.unpack $ unSchemaName (getSchemaName testEnvironment)
|
||||||
-- The error message we're looking out for if this fails is:
|
-- The error message we're looking out for if this fails is:
|
||||||
--
|
--
|
||||||
-- {
|
-- {
|
||||||
@ -84,5 +88,5 @@ tests _opts = do
|
|||||||
-- "path": "$"
|
-- "path": "$"
|
||||||
-- }
|
-- }
|
||||||
Postgres.runSQL
|
Postgres.runSQL
|
||||||
("alter table \"" ++ Constants.postgresDb ++ "\".\"author\" add column \"iae\" integer\n null;")
|
("alter table \"" ++ schemaName ++ "\".\"author\" add column \"iae\" integer\n null;")
|
||||||
testEnvironment
|
testEnvironment
|
||||||
|
@ -102,14 +102,14 @@ setupPostgres testEnvironment =
|
|||||||
Postgres.run_
|
Postgres.run_
|
||||||
testEnvironment
|
testEnvironment
|
||||||
[sql|
|
[sql|
|
||||||
CREATE OR REPLACE VIEW author_view
|
CREATE OR REPLACE VIEW hasura.author_view
|
||||||
AS SELECT * FROM author
|
AS SELECT * FROM hasura.author
|
||||||
|],
|
|],
|
||||||
Fixture.teardownAction = \_ ->
|
Fixture.teardownAction = \_ ->
|
||||||
Postgres.run_
|
Postgres.run_
|
||||||
testEnvironment
|
testEnvironment
|
||||||
[sql|
|
[sql|
|
||||||
DROP VIEW IF EXISTS author_view
|
DROP VIEW IF EXISTS hasura.author_view
|
||||||
|]
|
|]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user