mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 08:02:15 +03:00
GDC Mysql integration tests
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/7603 Co-authored-by: Daniel Chambers <1214352+daniel-chambers@users.noreply.github.com> GitOrigin-RevId: 651bc2fb59a46449e2a4325a4c7af57592e53845
This commit is contained in:
parent
b7c71468ae
commit
b3553ac88d
@ -147,3 +147,12 @@ services:
|
||||
# depends_on:
|
||||
# sqlserver:
|
||||
# condition: service_started
|
||||
|
||||
mysql:
|
||||
image: mysql
|
||||
command: --default-authentication-plugin=mysql_native_password
|
||||
restart: always
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: Password123#
|
||||
ports:
|
||||
- "3306:3306"
|
||||
|
@ -1,4 +1,5 @@
|
||||
API_TESTS_DOCKER_COMPOSE = docker compose --project-directory=./server/lib/api-tests
|
||||
API_PRO_TESTS_DOCKER_COMPOSE = docker compose --project-directory=./pro/server/lib/api-tests
|
||||
PYTHON_TESTS_DOCKER_COMPOSE = docker compose --project-directory=./server/tests-py
|
||||
|
||||
# Use the Azure SQL Edge image instead of the SQL Server image on arm64.
|
||||
@ -28,6 +29,7 @@ start-backends: build-backends
|
||||
## stop-everything: tear down test databases
|
||||
stop-everything:
|
||||
$(API_TESTS_DOCKER_COMPOSE) down --volumes
|
||||
$(API_PRO_TESTS_DOCKER_COMPOSE) down --volumes
|
||||
$(PYTHON_TESTS_DOCKER_COMPOSE) down --volumes
|
||||
|
||||
.PHONY: remove-tix-file
|
||||
|
@ -76,7 +76,7 @@ test-matrix: build remove-tix-file
|
||||
cabal run api-tests:exe:produce-feature-matrix +RTS -N4 -RTS
|
||||
|
||||
.PHONY: test-data-connectors-pro
|
||||
## test-backends-pro: run tests for HGE pro for all backends
|
||||
## test-data-connectors-pro: run tests for HGE pro for all backends
|
||||
test-data-connectors-pro: build-pro remove-tix-file
|
||||
docker compose up -d --wait postgres dc-sqlite-agent
|
||||
GRAPHQL_ENGINE=$(GRAPHQL_ENGINE_PRO_PATH) \
|
||||
@ -89,6 +89,22 @@ test-data-connectors-snowflake-pro: build-pro remove-tix-file
|
||||
GRAPHQL_ENGINE=$(GRAPHQL_ENGINE_PRO_PATH) \
|
||||
cabal run api-tests-pro:exe:api-tests-pro -- --match "DataConnector \"snowflake\""
|
||||
|
||||
.PHONY: test-data-connectors-athena-pro
|
||||
## test-data-connectors-athena-pro: run tests for HGE pro for all backends
|
||||
test-data-connectors-athena-pro: build-pro remove-tix-file
|
||||
docker compose up -d --wait postgres dc-sqlite-agent
|
||||
$(call stop_after, \
|
||||
GRAPHQL_ENGINE=$(GRAPHQL_ENGINE_PRO_PATH) \
|
||||
cabal run api-tests-pro:exe:api-tests-pro -- --match "DataConnector \"athena\"")
|
||||
|
||||
.PHONY: test-data-connectors-mysql-pro
|
||||
## test-data-connectors-mysql-pro: run tests for HGE pro for all backends
|
||||
test-data-connectors-mysql-pro: build-pro remove-tix-file
|
||||
cd pro/server/lib/api-tests && docker compose up -d --wait postgres dc-sqlite-agent --wait mysql
|
||||
$(call stop_after, \
|
||||
GRAPHQL_ENGINE=$(GRAPHQL_ENGINE_PRO_PATH) \
|
||||
cabal run api-tests-pro:exe:api-tests-pro -- --match "DataConnector \"mysql2\"")
|
||||
|
||||
.PHONY: test-backends-pro
|
||||
## test-backends-pro: run tests for HGE pro for all backends
|
||||
test-backends-pro: build-pro start-backends remove-tix-file
|
||||
|
@ -35,6 +35,7 @@ import Harness.Test.Fixture qualified as Fixture
|
||||
import Harness.TestEnvironment (GlobalTestEnvironment, TestEnvironment)
|
||||
import Harness.TestEnvironment qualified as TE
|
||||
import Harness.Yaml (shouldReturnYaml)
|
||||
import Hasura.Backends.DataConnector.API.V0 qualified as API
|
||||
import Hasura.Prelude
|
||||
import Test.Hspec (SpecWith, describe, it, pendingWith)
|
||||
|
||||
@ -271,27 +272,32 @@ objectRelatationshipsTests opts =
|
||||
|]
|
||||
|
||||
describe "Foreign Key Constraint On" $ do
|
||||
it "joins on PlaylistId" $ \(testEnvironment, _) ->
|
||||
shouldReturnYaml
|
||||
opts
|
||||
( GraphqlEngine.postGraphql
|
||||
testEnvironment
|
||||
[graphql|
|
||||
query getPlaylist {
|
||||
PlaylistTrack(where: {PlaylistId: {_eq: 1}, TrackId: {_eq: 2}}) {
|
||||
Playlist {
|
||||
Name
|
||||
}
|
||||
it "joins on PlaylistId" $ \(testEnvironment, _) -> do
|
||||
let dataSchema = (TE.getBackendTypeConfig testEnvironment >>= BackendType.parseCapabilities) <&> API._cDataSchema
|
||||
let supportsForeignKeys = any API._dscSupportsForeignKeys $ dataSchema
|
||||
if supportsForeignKeys
|
||||
then
|
||||
shouldReturnYaml
|
||||
opts
|
||||
( GraphqlEngine.postGraphql
|
||||
testEnvironment
|
||||
[graphql|
|
||||
query getPlaylist {
|
||||
PlaylistTrack(where: {PlaylistId: {_eq: 1}, TrackId: {_eq: 2}}) {
|
||||
Playlist {
|
||||
Name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|]
|
||||
)
|
||||
[yaml|
|
||||
data:
|
||||
PlaylistTrack:
|
||||
- Playlist:
|
||||
Name: "Music"
|
||||
|]
|
||||
)
|
||||
[yaml|
|
||||
data:
|
||||
PlaylistTrack:
|
||||
- Playlist:
|
||||
Name: "Music"
|
||||
|]
|
||||
else pendingWith "Backend does not support Foreign Key Constraints"
|
||||
|
||||
whereClauseTests :: Fixture.Options -> SpecWith (TestEnvironment, a)
|
||||
whereClauseTests opts =
|
||||
|
Loading…
Reference in New Issue
Block a user