Skip to content

Commit

Permalink
test(query-engine): fix some PlanetScale tests (#4909)
Browse files Browse the repository at this point in the history
* test(query-engine): Fix PlanetScale test, #4482

* test(query-engine): Fix PlanetScale test, #4485
  • Loading branch information
jkomyno committed Jun 7, 2024
1 parent a3ecb20 commit 9ee8c02
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ mod compound_fks {
schema.to_owned()
}

// "A One to Many relation with mixed requiredness" should "be writable and readable"-
// In PlanetScale, this fails with:
// `Expected result to return an error, but found success: {"data":{"createOnePost":{"id":2,"user_id":2,"user_age":2,"User":null}}}`
#[connector_test(exclude(MySql(5.6), MongoDb, Vitess("planetscale.js", "planetscale.js.wasm")))]
// "A One to Many relation with mixed requiredness" should "be writable and readable"
#[connector_test(exclude(MySql(5.6), MongoDb))]
async fn one2m_mix_required_writable_readable(runner: Runner) -> TestResult<()> {
use query_tests_setup::{ConnectorVersion, VitessVersion::*};

// Setup user
insta::assert_snapshot!(
run_query!(&runner, r#"mutation{createOneUser(data:{id: 1, nr:1, age: 1}){id, nr, age, Post{id}}}"#),
Expand All @@ -49,12 +49,17 @@ mod compound_fks {
@r###"{"data":{"createOnePost":{"id":1,"user_id":1,"user_age":null,"User":null}}}"###
);

// Foreign key violation
assert_error!(
&runner,
r#"mutation{createOnePost(data:{id: 2, user_id:2, user_age: 2}){id, user_id, user_age, User{id}}}"#,
2003
);
// Foreign key violation, which doesn't happen on PlanetScale.
if !matches!(
runner.connector_version(),
ConnectorVersion::Vitess(Some(PlanetscaleJsNapi)) | ConnectorVersion::Vitess(Some(PlanetscaleJsWasm))
) {
assert_error!(
&runner,
r#"mutation{createOnePost(data:{id: 2, user_id:2, user_age: 2}){id, user_id, user_age, User{id}}}"#,
2003
);
}

// Success
insta::assert_snapshot!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ mod update_many {
}

// "An updateMany mutation" should "correctly apply all number operations for Int"
#[connector_test(exclude(Vitess("planetscale.js", "planetscale.js.wasm"), CockroachDb))]
#[connector_test(exclude(CockroachDb))]
async fn apply_number_ops_for_int(runner: Runner) -> TestResult<()> {
create_row(&runner, r#"{ id: 1, optStr: "str1" }"#).await?;
create_row(&runner, r#"{ id: 2, optStr: "str2", optInt: 2 }"#).await?;
Expand Down Expand Up @@ -240,7 +240,7 @@ mod update_many {
}

// "An updateMany mutation" should "correctly apply all number operations for Float"
#[connector_test(exclude(Vitess("planetscale.js", "planetscale.js.wasm")))]
#[connector_test]
async fn apply_number_ops_for_float(runner: Runner) -> TestResult<()> {
create_row(&runner, r#"{ id: 1, optStr: "str1" }"#).await?;
create_row(&runner, r#"{ id: 2, optStr: "str2", optFloat: 2 }"#).await?;
Expand Down Expand Up @@ -297,10 +297,10 @@ mod update_many {
let count = &res["data"]["updateManyTestModel"]["count"];

// MySql does not count incrementing a null so the count is different
if !matches!(runner.connector_version(), ConnectorVersion::MySql(_)) {
// On PlanetScale, this fails with:
// left: Number(2)
// right: 3
if !matches!(
runner.connector_version(),
ConnectorVersion::MySql(_) | ConnectorVersion::Vitess(_)
) {
assert_eq!(count, 3);
}

Expand Down

0 comments on commit 9ee8c02

Please sign in to comment.