mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-09-11 02:35:32 +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
|
||||
module Test.Regression.UsingTheSameFunctionForRootFieldAndComputedField8643Spec (spec) where
|
||||
|
||||
-- import Data.Aeson (Value (Null))
|
||||
import Data.List.NonEmpty qualified as NE
|
||||
import Data.Text qualified as T
|
||||
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.Schema
|
||||
import Harness.Test.Schema qualified as Schema
|
||||
import Harness.TestEnvironment (TestEnvironment (..))
|
||||
-- import Harness.Yaml (shouldReturnYaml)
|
||||
import Hasura.Prelude
|
||||
import Test.Hspec
|
||||
|
||||
@ -54,20 +52,25 @@ schema =
|
||||
|
||||
functionSetup :: TestEnvironment -> Fixture.SetupAction
|
||||
functionSetup testEnvironment =
|
||||
Fixture.SetupAction
|
||||
{ setupAction =
|
||||
Postgres.run_ testEnvironment $
|
||||
"CREATE FUNCTION "
|
||||
++ Constants.postgresDb
|
||||
++ ".authors(author_row author) \
|
||||
\RETURNS SETOF author AS $$ \
|
||||
\ SELECT * \
|
||||
\ FROM "
|
||||
++ Constants.postgresDb
|
||||
++ ".author \
|
||||
\$$ LANGUAGE sql STABLE;",
|
||||
teardownAction = \_ -> Postgres.run_ testEnvironment $ "DROP FUNCTION " ++ Constants.postgresDb ++ ".authors;"
|
||||
}
|
||||
let schemaName = T.unpack $ unSchemaName (getSchemaName testEnvironment)
|
||||
in Fixture.SetupAction
|
||||
{ setupAction =
|
||||
Postgres.run_ testEnvironment $
|
||||
"CREATE FUNCTION "
|
||||
++ schemaName
|
||||
++ ".authors(author_row "
|
||||
++ schemaName
|
||||
++ ".author) \
|
||||
\RETURNS SETOF "
|
||||
++ schemaName
|
||||
++ ".author AS $$ \
|
||||
\ SELECT * \
|
||||
\ FROM "
|
||||
++ schemaName
|
||||
++ ".author \
|
||||
\$$ LANGUAGE sql STABLE;",
|
||||
teardownAction = \_ -> Postgres.run_ testEnvironment $ "DROP FUNCTION " ++ schemaName ++ ".authors;"
|
||||
}
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- Tests
|
||||
@ -76,6 +79,7 @@ tests :: Fixture.Options -> SpecWith TestEnvironment
|
||||
tests _opts = 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
|
||||
let schemaName = T.unpack $ unSchemaName (getSchemaName testEnvironment)
|
||||
-- The error message we're looking out for if this fails is:
|
||||
--
|
||||
-- {
|
||||
@ -84,5 +88,5 @@ tests _opts = do
|
||||
-- "path": "$"
|
||||
-- }
|
||||
Postgres.runSQL
|
||||
("alter table \"" ++ Constants.postgresDb ++ "\".\"author\" add column \"iae\" integer\n null;")
|
||||
("alter table \"" ++ schemaName ++ "\".\"author\" add column \"iae\" integer\n null;")
|
||||
testEnvironment
|
||||
|
@ -102,14 +102,14 @@ setupPostgres testEnvironment =
|
||||
Postgres.run_
|
||||
testEnvironment
|
||||
[sql|
|
||||
CREATE OR REPLACE VIEW author_view
|
||||
AS SELECT * FROM author
|
||||
CREATE OR REPLACE VIEW hasura.author_view
|
||||
AS SELECT * FROM hasura.author
|
||||
|],
|
||||
Fixture.teardownAction = \_ ->
|
||||
Postgres.run_
|
||||
testEnvironment
|
||||
[sql|
|
||||
DROP VIEW IF EXISTS author_view
|
||||
DROP VIEW IF EXISTS hasura.author_view
|
||||
|]
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user