Skip to content

Commit

Permalink
test(query-engine): Fix PlanetScale test, #4482
Browse files Browse the repository at this point in the history
  • Loading branch information
jkomyno committed Jun 6, 2024
1 parent 12e25d8 commit 8a7b4f7
Showing 1 changed file with 15 additions and 10 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

0 comments on commit 8a7b4f7

Please sign in to comment.