Skip to content

Commit

Permalink
Add update mutation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
karatakis committed Jul 28, 2023
1 parent 53ba9a3 commit 2e65a25
Show file tree
Hide file tree
Showing 3 changed files with 538 additions and 1 deletion.
179 changes: 179 additions & 0 deletions examples/mysql/tests/mutation_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]
}
}
"#,
);
}
181 changes: 180 additions & 1 deletion examples/postgres/tests/mutation_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
"#,
Expand Down Expand Up @@ -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
}
]
}
}
"#,
);
}
Loading

0 comments on commit 2e65a25

Please sign in to comment.