mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-16 01:44:03 +03:00
45843b94d9
Fixes https://github.com/hasura/graphql-engine-mono/issues/4546
Error: `Bigquery HTTP request failed with status code 400 and status message "Bad Request" `
Likely fix: untrack `author` table before dropping it in `SerializationSpec`. [This is the main change](fadbbfe8f2
), the rest is cleanup.
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/4548
GitOrigin-RevId: 36be213d8ccfeb2dbb6b797225dc07e6e3dc83ba
107 lines
2.6 KiB
Haskell
107 lines
2.6 KiB
Haskell
{-# LANGUAGE QuasiQuotes #-}
|
|
|
|
-- | Serialization test for specific data types
|
|
module Test.SerializationSpec (spec) where
|
|
|
|
import Harness.Backend.BigQuery qualified as Bigquery
|
|
import Harness.GraphqlEngine qualified as GraphqlEngine
|
|
import Harness.Quoter.Graphql (graphql)
|
|
import Harness.Quoter.Sql
|
|
import Harness.Quoter.Yaml (shouldReturnYaml, yaml)
|
|
import Harness.Test.Context qualified as Context
|
|
import Harness.Test.Schema qualified as Schema
|
|
import Harness.TestEnvironment (TestEnvironment)
|
|
import Test.Hspec (SpecWith, describe, it)
|
|
import Prelude
|
|
|
|
--------------------------------------------------------------------------------
|
|
-- Preamble
|
|
|
|
spec :: SpecWith TestEnvironment
|
|
spec =
|
|
Context.run
|
|
[ Context.Context
|
|
{ name = Context.Backend Context.BigQuery,
|
|
mkLocalTestEnvironment = Context.noLocalTestEnvironment,
|
|
setup = bigquerySetup,
|
|
teardown = Bigquery.teardown [author],
|
|
customOptions = Nothing
|
|
}
|
|
]
|
|
tests
|
|
|
|
author :: Schema.Table
|
|
author =
|
|
Schema.Table
|
|
{ tableName = "author",
|
|
tableColumns = [],
|
|
tablePrimaryKey = [],
|
|
tableReferences = [],
|
|
tableData = []
|
|
}
|
|
|
|
bigquerySetup :: (TestEnvironment, ()) -> IO ()
|
|
bigquerySetup (testEnvironment, _) = do
|
|
sourceMetadata <- Bigquery.defaultSourceMetadata
|
|
GraphqlEngine.postMetadata_ testEnvironment sourceMetadata
|
|
|
|
Bigquery.runSql_
|
|
[sql|
|
|
CREATE TABLE hasura.author (
|
|
id INT,
|
|
name STRING,
|
|
tax_id DECIMAL,
|
|
total_books BIGDECIMAL
|
|
);
|
|
|]
|
|
Bigquery.runSql_
|
|
[sql|
|
|
INSERT hasura.author (id, name, tax_id, total_books)
|
|
VALUES (1, "sibi", 5555555555555556666, 5555555555555556666);
|
|
|]
|
|
|
|
Bigquery.trackTable testEnvironment author
|
|
|
|
tests :: Context.Options -> SpecWith TestEnvironment
|
|
tests opts = describe "SerializationSpec" $ do
|
|
it "serde Decimal column" $ \testEnvironment ->
|
|
shouldReturnYaml
|
|
opts
|
|
( GraphqlEngine.postGraphql
|
|
testEnvironment
|
|
[graphql|
|
|
query MyQuery {
|
|
hasura_author(where: {tax_id: {_eq: 5555555555555556666}}) {
|
|
id
|
|
tax_id
|
|
}
|
|
}|]
|
|
)
|
|
[yaml|
|
|
data:
|
|
hasura_author:
|
|
- tax_id: "5555555555555556666"
|
|
id: "1"
|
|
|]
|
|
it "serde BigDecimal column" $ \testEnvironment ->
|
|
shouldReturnYaml
|
|
opts
|
|
( GraphqlEngine.postGraphql
|
|
testEnvironment
|
|
[graphql|
|
|
query MyQuery {
|
|
hasura_author(where: {total_books: {_eq: 5555555555555556666}}) {
|
|
id
|
|
tax_id
|
|
total_books
|
|
}
|
|
}|]
|
|
)
|
|
[yaml|
|
|
data:
|
|
hasura_author:
|
|
- tax_id: "5555555555555556666"
|
|
total_books: "5555555555555556666"
|
|
id: "1"
|
|
|]
|