From f12ecb9dade9be29e4abe778aa962443667b79ad Mon Sep 17 00:00:00 2001 From: Panagiotis Karatakis Date: Fri, 28 Jul 2023 16:55:40 +0300 Subject: [PATCH] Add update mutation tests --- examples/mysql/tests/mutation_tests.rs | 179 +++++++++++++++++++++ examples/postgres/tests/mutation_tests.rs | 181 +++++++++++++++++++++- examples/sqlite/sakila.db | Bin 5824512 -> 5828608 bytes examples/sqlite/tests/mutation_tests.rs | 179 +++++++++++++++++++++ 4 files changed, 538 insertions(+), 1 deletion(-) diff --git a/examples/mysql/tests/mutation_tests.rs b/examples/mysql/tests/mutation_tests.rs index 73e0b407..b0c4e2e3 100644 --- a/examples/mysql/tests/mutation_tests.rs +++ b/examples/mysql/tests/mutation_tests.rs @@ -359,3 +359,182 @@ async fn test_create_batch_mutation() { "#, ) } + +#[tokio::test] +async fn test_update_mutation() { + let schema = get_schema().await; + + assert_eq( + schema + .execute( + r#" + { + country(pagination: { page: { limit: 10, page: 0 } }) { + nodes { + country + countryId + } + } + } + "#, + ) + .await, + r#" + { + "country": { + "nodes": [ + { + "country": "Afghanistan", + "countryId": 1 + }, + { + "country": "Algeria", + "countryId": 2 + }, + { + "country": "American Samoa", + "countryId": 3 + }, + { + "country": "Angola", + "countryId": 4 + }, + { + "country": "Anguilla", + "countryId": 5 + }, + { + "country": "Argentina", + "countryId": 6 + }, + { + "country": "Armenia", + "countryId": 7 + }, + { + "country": "Australia", + "countryId": 8 + }, + { + "country": "Austria", + "countryId": 9 + }, + { + "country": "Azerbaijan", + "countryId": 10 + } + ] + } + } + "#, + ); + + assert_eq( + schema + .execute( + r#" + mutation { + countryUpdate( + data: { country: "[DELETED]" } + filter: { countryId: { lt: 6 } } + ) { + countryId + country + } + } + "#, + ) + .await, + r#" + { + "countryUpdate": [ + { + "countryId": 1, + "country": "[DELETED]" + }, + { + "countryId": 2, + "country": "[DELETED]" + }, + { + "countryId": 3, + "country": "[DELETED]" + }, + { + "countryId": 4, + "country": "[DELETED]" + }, + { + "countryId": 5, + "country": "[DELETED]" + } + ] + } + "#, + ); + + assert_eq( + schema + .execute( + r#" + { + country(pagination: { page: { limit: 10, page: 0 } }) { + nodes { + country + countryId + } + } + } + "#, + ) + .await, + r#" + { + "country": { + "nodes": [ + { + "country": "[DELETED]", + "countryId": 1 + }, + { + "country": "[DELETED]", + "countryId": 2 + }, + { + "country": "[DELETED]", + "countryId": 3 + }, + { + "country": "[DELETED]", + "countryId": 4 + }, + { + "country": "[DELETED]", + "countryId": 5 + }, + { + "country": "Argentina", + "countryId": 6 + }, + { + "country": "Armenia", + "countryId": 7 + }, + { + "country": "Australia", + "countryId": 8 + }, + { + "country": "Austria", + "countryId": 9 + }, + { + "country": "Azerbaijan", + "countryId": 10 + } + ] + } + } + "#, + ); +} diff --git a/examples/postgres/tests/mutation_tests.rs b/examples/postgres/tests/mutation_tests.rs index 5a8ceeb0..7d7da73c 100644 --- a/examples/postgres/tests/mutation_tests.rs +++ b/examples/postgres/tests/mutation_tests.rs @@ -62,7 +62,7 @@ async fn test_simple_insert_one() { filmActorCreateOne(data: { actorId: 1, filmId: 2, lastUpdate: "2030-01-01 11:11:11"}) { actorId filmId - __typename + __typename } } "#, @@ -361,3 +361,182 @@ async fn test_create_batch_mutation() { "#, ) } + +#[tokio::test] +async fn test_update_mutation() { + let schema = get_schema().await; + + assert_eq( + schema + .execute( + r#" + { + country(pagination: { page: { limit: 10, page: 0 } }) { + nodes { + country + countryId + } + } + } + "#, + ) + .await, + r#" + { + "country": { + "nodes": [ + { + "country": "Afghanistan", + "countryId": 1 + }, + { + "country": "Algeria", + "countryId": 2 + }, + { + "country": "American Samoa", + "countryId": 3 + }, + { + "country": "Angola", + "countryId": 4 + }, + { + "country": "Anguilla", + "countryId": 5 + }, + { + "country": "Argentina", + "countryId": 6 + }, + { + "country": "Armenia", + "countryId": 7 + }, + { + "country": "Australia", + "countryId": 8 + }, + { + "country": "Austria", + "countryId": 9 + }, + { + "country": "Azerbaijan", + "countryId": 10 + } + ] + } + } + "#, + ); + + assert_eq( + schema + .execute( + r#" + mutation { + countryUpdate( + data: { country: "[DELETED]" } + filter: { countryId: { lt: 6 } } + ) { + countryId + country + } + } + "#, + ) + .await, + r#" + { + "countryUpdate": [ + { + "countryId": 1, + "country": "[DELETED]" + }, + { + "countryId": 2, + "country": "[DELETED]" + }, + { + "countryId": 3, + "country": "[DELETED]" + }, + { + "countryId": 4, + "country": "[DELETED]" + }, + { + "countryId": 5, + "country": "[DELETED]" + } + ] + } + "#, + ); + + assert_eq( + schema + .execute( + r#" + { + country(pagination: { page: { limit: 10, page: 0 } }) { + nodes { + country + countryId + } + } + } + "#, + ) + .await, + r#" + { + "country": { + "nodes": [ + { + "country": "[DELETED]", + "countryId": 1 + }, + { + "country": "[DELETED]", + "countryId": 2 + }, + { + "country": "[DELETED]", + "countryId": 3 + }, + { + "country": "[DELETED]", + "countryId": 4 + }, + { + "country": "[DELETED]", + "countryId": 5 + }, + { + "country": "Argentina", + "countryId": 6 + }, + { + "country": "Armenia", + "countryId": 7 + }, + { + "country": "Australia", + "countryId": 8 + }, + { + "country": "Austria", + "countryId": 9 + }, + { + "country": "Azerbaijan", + "countryId": 10 + } + ] + } + } + "#, + ); +} diff --git a/examples/sqlite/sakila.db b/examples/sqlite/sakila.db index e511f1975e04405cb48deacc3f70060ef3e47c92..fb52ff3ffd6d5d6d1c1326e2cdabb4e830030d03 100644 GIT binary patch delta 3163 zcmaKu3se->8OQI;-I<-4ot-=TKtTl;!38ABvI~evSP4QfMMa?EBTclmHl{uZiAhOM ztEdf4%&8#C)ni3GYK}FJg2s$CN>EelgQH-Lf|vxfX)&gX)>L!a*nV?IkDi{?bN09Y z`#tWRJ9l=!ZY;HhvB7{anhlJe4 zKUun9VSQh2#IjhyoGLtOYOKvnu{|;cn<@BFDL&374-frshWhXxSKgg!+?~pawVFm| zatLwhUSE8)PK*a;an}+`$bI^Bg)k2NH-K^E^L;51A)LU%Jlyf~<9?K@Pei zVva9Ru6{7U*@`8ebRu$vbQ-Q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