From 654ed15d63f1da6898eba86d060071ef4b82a97b Mon Sep 17 00:00:00 2001 From: Panagiotis Karatakis Date: Wed, 11 Oct 2023 01:40:58 +0300 Subject: [PATCH] Fix mysql and postgresql tests --- examples/mysql/tests/mutation_tests.rs | 37 ++------ examples/postgres/tests/mutation_tests.rs | 107 +++++++++++++++------- 2 files changed, 83 insertions(+), 61 deletions(-) diff --git a/examples/mysql/tests/mutation_tests.rs b/examples/mysql/tests/mutation_tests.rs index 653937d0..87285c21 100644 --- a/examples/mysql/tests/mutation_tests.rs +++ b/examples/mysql/tests/mutation_tests.rs @@ -537,29 +537,12 @@ async fn test_update_mutation() { async fn test_delete_mutation() { let schema = get_schema().await; - schema.execute( - r#" - mutation { - filmTextCreateBatch( - data: [ - { filmId: 6, title: "TEST 6", description: "TEST DESC 6" } - { filmId: 7, title: "TEST 7", description: "TEST DESC 7" } - { filmId: 8, title: "TEST 8", description: "TEST DESC 8" } - ] - ) { - filmId - } - } - "# - ) - .await; - assert_eq( schema .execute( r#" { - filmText(filters: { filmId: { gte: 6 } }, orderBy: { filmId: ASC }) { + filmText(filters: { filmId: { gte: 998 } }, orderBy: { filmId: ASC }) { nodes { filmId title @@ -574,16 +557,16 @@ async fn test_delete_mutation() { "filmText": { "nodes": [ { - "filmId": 6, - "title": "TEST 6" + "filmId": 998, + "title": "ZHIVAGO CORE" }, { - "filmId": 7, - "title": "TEST 7" + "filmId": 999, + "title": "ZOOLANDER FICTION" }, { - "filmId": 8, - "title": "TEST 8" + "filmId": 1000, + "title": "ZORRO ARK" } ] } @@ -596,7 +579,7 @@ async fn test_delete_mutation() { .execute( r#" mutation { - filmTextDelete(filter: { filmId: { gte: 7 } }) + filmTextDelete(filter: { filmId: { gte: 999 } }) } "#, ) @@ -628,8 +611,8 @@ async fn test_delete_mutation() { "filmText": { "nodes": [ { - "filmId": 6, - "title": "TEST 6" + "filmId": 998, + "title": "ZHIVAGO CORE" } ] } diff --git a/examples/postgres/tests/mutation_tests.rs b/examples/postgres/tests/mutation_tests.rs index 7646b70a..a47a7ab5 100644 --- a/examples/postgres/tests/mutation_tests.rs +++ b/examples/postgres/tests/mutation_tests.rs @@ -218,7 +218,7 @@ async fn test_create_batch_mutation() { .execute( r#" { - language { + language(filters: { languageId: { lt: 9 } }, orderBy: { languageId: ASC }) { nodes { languageId name @@ -301,7 +301,7 @@ async fn test_create_batch_mutation() { .execute( r#" { - language { + language(filters: { languageId: { lt: 9 } }, orderBy: { languageId: ASC }) { nodes { languageId name @@ -506,53 +506,93 @@ async fn test_update_mutation() { async fn test_delete_mutation() { let schema = get_schema().await; - schema.execute( + assert_eq( + schema + .execute( + r#" + { + language(filters: { languageId: { gte: 9 } }, orderBy: { languageId: ASC }) { + nodes { + languageId + } + } + } + + "#, + ) + .await, r#" - mutation { - filmTextCreateBatch( - data: [ - { filmId: 6, title: "TEST 6", description: "TEST DESC 6" } - { filmId: 7, title: "TEST 7", description: "TEST DESC 7" } - { filmId: 8, title: "TEST 8", description: "TEST DESC 8" } - ] - ) { - filmId + { + "language": { + "nodes": [] + } } - } - "# - ) - .await; + "#, + ); + + assert_eq( + schema + .execute( + r#" + mutation { + languageCreateBatch( + data: [ + { languageId: 9, name: "9", lastUpdate: "2030-01-12 21:50:05" } + { languageId: 10, name: "10", lastUpdate: "2030-01-12 21:50:05" } + { languageId: 11, name: "11", lastUpdate: "2030-01-12 21:50:05" } + ] + ) { + languageId + } + } + + "#, + ) + .await, + r#" + { + "languageCreateBatch": [ + { + "languageId": 9, + }, + { + "languageId": 10, + }, + { + "languageId": 11, + } + ] + } + "#, + ); assert_eq( schema .execute( r#" { - filmText(filters: { filmId: { gte: 6 } }, orderBy: { filmId: ASC }) { + language(filters: { languageId: { gte: 9 } }, orderBy: { languageId: ASC }) { nodes { - filmId - title + languageId } } } + "#, ) .await, r#" { - "filmText": { + "language": { "nodes": [ { - "filmId": 6, - "title": "TEST 6" + "languageId": 9 }, { - "filmId": 7, - "title": "TEST 7" + "languageId": 10 }, { - "filmId": 8, - "title": "TEST 8" + "languageId": 11 } ] } @@ -565,7 +605,7 @@ async fn test_delete_mutation() { .execute( r#" mutation { - filmTextDelete(filter: { filmId: { gte: 7 } }) + languageDelete(filter: { languageId: { gte: 10 } }) } "#, ) @@ -582,27 +622,26 @@ async fn test_delete_mutation() { .execute( r#" { - filmText(filters: { filmId: { gte: 6 } }, orderBy: { filmId: ASC }) { + language(filters: { languageId: { gte: 9 } }, orderBy: { languageId: ASC }) { nodes { - filmId - title + languageId } } } + "#, ) .await, r#" { - "filmText": { + "language": { "nodes": [ { - "filmId": 6, - "title": "TEST 6" + "languageId": 9 } ] } } "#, ); -} +} \ No newline at end of file