Skip to content

Commit

Permalink
Fix mysql and postgresql tests
Browse files Browse the repository at this point in the history
  • Loading branch information
karatakis committed Oct 10, 2023
1 parent 856cb21 commit 654ed15
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 61 deletions.
37 changes: 10 additions & 27 deletions examples/mysql/tests/mutation_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
}
]
}
Expand All @@ -596,7 +579,7 @@ async fn test_delete_mutation() {
.execute(
r#"
mutation {
filmTextDelete(filter: { filmId: { gte: 7 } })
filmTextDelete(filter: { filmId: { gte: 999 } })
}
"#,
)
Expand Down Expand Up @@ -628,8 +611,8 @@ async fn test_delete_mutation() {
"filmText": {
"nodes": [
{
"filmId": 6,
"title": "TEST 6"
"filmId": 998,
"title": "ZHIVAGO CORE"
}
]
}
Expand Down
107 changes: 73 additions & 34 deletions examples/postgres/tests/mutation_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ async fn test_create_batch_mutation() {
.execute(
r#"
{
language {
language(filters: { languageId: { lt: 9 } }, orderBy: { languageId: ASC }) {
nodes {
languageId
name
Expand Down Expand Up @@ -301,7 +301,7 @@ async fn test_create_batch_mutation() {
.execute(
r#"
{
language {
language(filters: { languageId: { lt: 9 } }, orderBy: { languageId: ASC }) {
nodes {
languageId
name
Expand Down Expand Up @@ -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
}
]
}
Expand All @@ -565,7 +605,7 @@ async fn test_delete_mutation() {
.execute(
r#"
mutation {
filmTextDelete(filter: { filmId: { gte: 7 } })
languageDelete(filter: { languageId: { gte: 10 } })
}
"#,
)
Expand All @@ -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
}
]
}
}
"#,
);
}
}

0 comments on commit 654ed15

Please sign in to comment.