Skip to content

Commit

Permalink
Merge pull request prisma#2370 from graphcool/enable-passive-tests
Browse files Browse the repository at this point in the history
enable passive postgres tests
  • Loading branch information
mavilein authored May 8, 2018
2 parents d5c32dd + 19a69c0 commit 5b926a4
Show file tree
Hide file tree
Showing 16 changed files with 89 additions and 64 deletions.
3 changes: 1 addition & 2 deletions server/.buildkite/pipeline.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#! /bin/bash

#declare -a connectors=(mysql postgres postgres-passive)
declare -a connectors=(mysql postgres)
declare -a connectors=(mysql postgres postgres-passive)

# Projects with a locked connector
static=$(printf " - label: \":mysql: MySql API connector\"
Expand Down
3 changes: 2 additions & 1 deletion server/docker-compose/postgres/prisma_passive.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ databases:
host: 127.0.0.1
port: 5432
user: postgres
password: prisma
password: prisma
database: prisma
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.prisma.api

import com.prisma.shared.schema_dsl.SchemaDsl
import org.scalatest.{FlatSpec, Matchers}
import org.scalatest.{Assertion, FlatSpec, Matchers}

class Queries extends FlatSpec with Matchers with ApiSpecBase {

Expand Down Expand Up @@ -29,7 +29,7 @@ class Queries extends FlatSpec with Matchers with ApiSpecBase {
server.query("""{cars{wheelCount}}""", project).pathAsLong("data.cars.[0].wheelCount") should be(8)
server.query("""{carsConnection{edges{node{wheelCount}}}}""", project).pathAsLong("data.carsConnection.edges.[0].node.wheelCount") should be(8)
server.query(s"""{car(where: {id:"${newId}"}){wheelCount}}""", project).pathAsLong("data.car.wheelCount") should be(8)
server.query(s"""{node(id:"${newId}"){... on Car { wheelCount }}}""", project).pathAsLong("data.node.wheelCount") should be(8)
ifConnectorIsActive { server.query(s"""{node(id:"${newId}"){... on Car { wheelCount }}}""", project).pathAsLong("data.node.wheelCount") should be(8) }
}

"schema" should "include old nested mutations" in {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ class CascadingDeleteSpec extends FlatSpec with Matchers with ApiSpecBase {
server.query("""mutation{deleteP(where: {p:"p"}){id}}""", project)
server.query("""query{ps{p, c {c}}}""", project).toString should be("""{"data":{"ps":[{"p":"p2","c":{"c":"c2"}}]}}""")
server.query("""query{cs{c, p {p}}}""", project).toString should be("""{"data":{"cs":[{"c":"c2","p":{"p":"p2"}}]}}""")
dataResolver(project).countByTable("_RelayId").await should be(2)

ifConnectorIsActive { dataResolver(project).countByTable("_RelayId").await should be(2) }
}

"PM-CM relation deleting the parent" should "delete all children if the parent is marked cascading" in {
Expand All @@ -45,7 +46,8 @@ class CascadingDeleteSpec extends FlatSpec with Matchers with ApiSpecBase {
server.query("""mutation{deleteP(where: {p:"p"}){id}}""", project)
server.query("""query{ps{p, c {c}}}""", project).toString should be("""{"data":{"ps":[{"p":"p2","c":[{"c":"cx"},{"c":"cx2"}]},{"p":"pz","c":[]}]}}""")
server.query("""query{cs{c, p {p}}}""", project).toString should be("""{"data":{"cs":[{"c":"cx","p":[{"p":"p2"}]},{"c":"cx2","p":[{"p":"p2"}]}]}}""")
dataResolver(project).countByTable("_RelayId").await should be(4)

ifConnectorIsActive { dataResolver(project).countByTable("_RelayId").await should be(4) }
}

"PM-CM relation deleting the parent" should "error if both sides are marked cascading since it would be a circle" in {
Expand All @@ -64,7 +66,8 @@ class CascadingDeleteSpec extends FlatSpec with Matchers with ApiSpecBase {
server.queryThatMustFail("""mutation{deleteP(where: {p:"p"}){id}}""", project, errorCode = 3043)
server.query("""query{ps{p, c {c}}}""", project).toString should be(
"""{"data":{"ps":[{"p":"p","c":[{"c":"c"},{"c":"c2"}]},{"p":"pz","c":[{"c":"c2"}]}]}}""")
dataResolver(project).countByTable("_RelayId").await should be(4)

ifConnectorIsActive { dataResolver(project).countByTable("_RelayId").await should be(4) }
}

"P1!-C1! relation deleting the parent" should "error if both sides are marked marked cascading" in {
Expand All @@ -81,7 +84,8 @@ class CascadingDeleteSpec extends FlatSpec with Matchers with ApiSpecBase {

server.queryThatMustFail("""mutation{deleteP(where: {p:"p"}){id}}""", project, errorCode = 3043)
server.query("""query{ps{p, c {c}}}""", project).toString should be("""{"data":{"ps":[{"p":"p","c":{"c":"c"}}]}}""")
dataResolver(project).countByTable("_RelayId").await should be(2)

ifConnectorIsActive { dataResolver(project).countByTable("_RelayId").await should be(2) }
}

"P1!-C1! relation deleting the parent" should "error if only child is marked marked cascading" in {
Expand All @@ -101,7 +105,7 @@ class CascadingDeleteSpec extends FlatSpec with Matchers with ApiSpecBase {
server.query("""query{ps{p, c {c}}}""", project).toString should be("""{"data":{"ps":[{"p":"p","c":{"c":"c"}},{"p":"p2","c":{"c":"c2"}}]}}""")
server.query("""query{cs{c, p {p}}}""", project).toString should be("""{"data":{"cs":[{"c":"c","p":{"p":"p"}},{"c":"c2","p":{"p":"p2"}}]}}""")

dataResolver(project).countByTable("_RelayId").await should be(4)
ifConnectorIsActive { dataResolver(project).countByTable("_RelayId").await should be(4) }
}

"P1!-C1!-C1!-GC! relation deleting the parent and child and grandchild if marked cascading" should "work" in {
Expand All @@ -125,7 +129,7 @@ class CascadingDeleteSpec extends FlatSpec with Matchers with ApiSpecBase {
server.query("""query{cs{c, gc{gc}, p {p}}}""", project).toString should be("""{"data":{"cs":[{"c":"c2","gc":{"gc":"gc2"},"p":{"p":"p2"}}]}}""")
server.query("""query{gCs{gc, c {c, p{p}}}}""", project).toString should be("""{"data":{"gCs":[{"gc":"gc2","c":{"c":"c2","p":{"p":"p2"}}}]}}""")

dataResolver(project).countByTable("_RelayId").await should be(3)
ifConnectorIsActive { dataResolver(project).countByTable("_RelayId").await should be(3) }
}

"P1!-C1!-C1-GC relation deleting the parent and child marked cascading" should "work but preserve the grandchild" in {
Expand All @@ -150,7 +154,7 @@ class CascadingDeleteSpec extends FlatSpec with Matchers with ApiSpecBase {
server.query("""query{gCs{gc, c {c, p{p}}}}""", project).toString should be(
"""{"data":{"gCs":[{"gc":"gc","c":null},{"gc":"gc2","c":{"c":"c2","p":{"p":"p2"}}}]}}""")

dataResolver(project).countByTable("_RelayId").await should be(4)
ifConnectorIsActive { dataResolver(project).countByTable("_RelayId").await should be(4) }
}

"P1!-C1! relation deleting the parent marked cascading" should "error if the child is required in another non-cascading relation" in {
Expand All @@ -172,7 +176,7 @@ class CascadingDeleteSpec extends FlatSpec with Matchers with ApiSpecBase {
server.query("""query{ps{p, c {c}}}""", project).toString should be("""{"data":{"ps":[{"p":"p","c":{"c":"c"}},{"p":"p2","c":{"c":"c2"}}]}}""")
server.query("""query{cs{c, p {p}}}""", project).toString should be("""{"data":{"cs":[{"c":"c","p":{"p":"p"}},{"c":"c2","p":{"p":"p2"}}]}}""")

dataResolver(project).countByTable("_RelayId").await should be(6)
ifConnectorIsActive { dataResolver(project).countByTable("_RelayId").await should be(6) }
}

"If the parent is not cascading nothing on the path" should "be deleted except for the parent" in {
Expand All @@ -194,7 +198,7 @@ class CascadingDeleteSpec extends FlatSpec with Matchers with ApiSpecBase {
server.query("""query{cs{c, p {p}}}""", project).toString should be("""{"data":{"cs":[{"c":"c","p":null}]}}""")
server.query("""query{gCs{gc, c {c}}}""", project).toString should be("""{"data":{"gCs":[{"gc":"gc","c":{"c":"c"}}]}}""")

dataResolver(project).countByTable("_RelayId").await should be(2)
ifConnectorIsActive { dataResolver(project).countByTable("_RelayId").await should be(2) }
}

"P1!-C1! PM-SC1! relation deleting the parent marked cascading" should "work" in {
Expand Down Expand Up @@ -223,7 +227,7 @@ class CascadingDeleteSpec extends FlatSpec with Matchers with ApiSpecBase {
server.query("""query{cs{c, p {p}}}""", project).toString should be("""{"data":{"cs":[{"c":"c2","p":{"p":"p2"}}]}}""")
server.query("""query{sCs{sc, p{p}}}""", project).toString should be("""{"data":{"sCs":[{"sc":"sc3","p":{"p":"p2"}},{"sc":"sc4","p":{"p":"p2"}}]}}""")

dataResolver(project).countByTable("_RelayId").await should be(4)
ifConnectorIsActive { dataResolver(project).countByTable("_RelayId").await should be(4) }
}

"P!->C PM->SC relation without backrelations" should "work when deleting the parent marked cascading" in {
Expand Down Expand Up @@ -253,7 +257,7 @@ class CascadingDeleteSpec extends FlatSpec with Matchers with ApiSpecBase {
server.query("""query{cs{c}}""", project).toString should be("""{"data":{"cs":[{"c":"c2"}]}}""")
server.query("""query{sCs{sc}}""", project).toString should be("""{"data":{"sCs":[]}}""")

dataResolver(project).countByTable("_RelayId").await should be(1)
ifConnectorIsActive { dataResolver(project).countByTable("_RelayId").await should be(1) }
}

"A path that is interrupted since there are nodes missing" should "only cascade up until the gap" in {
Expand Down Expand Up @@ -284,7 +288,7 @@ class CascadingDeleteSpec extends FlatSpec with Matchers with ApiSpecBase {
server.query("""query{ds{d, gc {gc},e {e}}}""", project).toString should be("""{"data":{"ds":[{"d":"d","gc":[],"e":[{"e":"e"}]}]}}""")
server.query("""query{es{e, d {d}}}""", project).toString should be("""{"data":{"es":[{"e":"e","d":[{"d":"d"}]}]}}""")

dataResolver(project).countByTable("_RelayId").await should be(5)
ifConnectorIsActive { dataResolver(project).countByTable("_RelayId").await should be(5) }
}

"A deep uninterrupted path" should "cascade all the way down" in {
Expand Down Expand Up @@ -315,7 +319,7 @@ class CascadingDeleteSpec extends FlatSpec with Matchers with ApiSpecBase {
server.query("""query{ds{d, gc {gc},e {e}}}""", project).toString should be("""{"data":{"ds":[]}}""")
server.query("""query{es{e, d {d}}}""", project).toString should be("""{"data":{"es":[]}}""")

dataResolver(project).countByTable("_RelayId").await should be(3)
ifConnectorIsActive { dataResolver(project).countByTable("_RelayId").await should be(3) }
}

"A deep uninterrupted path" should "error on a required relation violation at the end" in {
Expand Down Expand Up @@ -355,7 +359,7 @@ class CascadingDeleteSpec extends FlatSpec with Matchers with ApiSpecBase {
server.query("""query{ds{d, gc {gc},e {e}}}""", project).toString should be("""{"data":{"ds":[{"d":"d","gc":[{"gc":"gc"}],"e":[{"e":"e"}]}]}}""")
server.query("""query{fs{f, e {e}}}""", project).toString should be("""{"data":{"fs":[{"f":"f","e":{"e":"e"}}]}}""")

dataResolver(project).countByTable("_RelayId").await should be(9)
ifConnectorIsActive { dataResolver(project).countByTable("_RelayId").await should be(9) }
}

"A required relation violation anywhere on the path" should "error and roll back all of the changes" in {
Expand Down Expand Up @@ -434,7 +438,7 @@ class CascadingDeleteSpec extends FlatSpec with Matchers with ApiSpecBase {
errorContains = "The change you are trying to make would violate the required relation '_AToD' between A and D"
)

dataResolver(project).countByTable("_RelayId").await should be(7)
ifConnectorIsActive { dataResolver(project).countByTable("_RelayId").await should be(7) }
}

"Several relations between the same model" should "be handled correctly" in {
Expand Down Expand Up @@ -505,7 +509,7 @@ class CascadingDeleteSpec extends FlatSpec with Matchers with ApiSpecBase {
errorContains = "No Node for the model")
server.query("""query{ps{p, c {c}}}""", project).toString should be("""{"data":{"ps":[{"p":"p2","c":{"c":"c2"}}]}}""")
server.query("""query{cs{c, p {p}}}""", project).toString should be("""{"data":{"cs":[{"c":"c2","p":{"p":"p2"}}]}}""")
dataResolver(project).countByTable("_RelayId").await should be(2)
ifConnectorIsActive { dataResolver(project).countByTable("_RelayId").await should be(2) }
}

"P1-C1-C1!-GC! relation updating the parent to delete the child and grandchild if marked cascading" should "work" in {
Expand All @@ -530,7 +534,7 @@ class CascadingDeleteSpec extends FlatSpec with Matchers with ApiSpecBase {
server.query("""query{cs{c, gc{gc}, p {p}}}""", project).toString should be("""{"data":{"cs":[{"c":"c2","gc":{"gc":"gc2"},"p":{"p":"p2"}}]}}""")
server.query("""query{gCs{gc, c {c, p{p}}}}""", project).toString should be("""{"data":{"gCs":[{"gc":"gc2","c":{"c":"c2","p":{"p":"p2"}}}]}}""")

dataResolver(project).countByTable("_RelayId").await should be(4)
ifConnectorIsActive { dataResolver(project).countByTable("_RelayId").await should be(4) }
}

"P1!-C1!-C1!-GC! relation updating the parent to delete the child and grandchild if marked cascading" should "error if the child is required on parent" in {
Expand Down Expand Up @@ -562,7 +566,7 @@ class CascadingDeleteSpec extends FlatSpec with Matchers with ApiSpecBase {
server.query("""query{gCs{gc, c {c, p{p}}}}""", project).toString should be(
"""{"data":{"gCs":[{"gc":"gc","c":{"c":"c","p":{"p":"p"}}},{"gc":"gc2","c":{"c":"c2","p":{"p":"p2"}}}]}}""")

dataResolver(project).countByTable("_RelayId").await should be(6)
ifConnectorIsActive { dataResolver(project).countByTable("_RelayId").await should be(6) }
}
//endregion
}
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,7 @@ class DeleteManySpec extends FlatSpec with Matchers with ApiSpecBase {
)
result.pathAsSeq("data.todoes").size should be(int)

dataResolver(project).countByTable("_RelayId").await should be(int)

ifConnectorIsActive { dataResolver(project).countByTable("_RelayId").await should be(int) }
}

def createTodo(title: String): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ class DeleteSpec extends FlatSpec with Matchers with ApiSpecBase {
)
result.pathAsSeq("data.todoes").size should be(int)

dataResolver(project).countByTable("_RelayId").await should be(int)

ifConnectorIsActive { dataResolver(project).countByTable("_RelayId").await should be(int) }
}

def createTodo(title: String): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,8 +692,7 @@ class NestedDeleteMutationInsideUpdateSpec extends FlatSpec with Matchers with A

val query = server.query("""{ comments { id }}""", project)
mustBeEqual(query.toString, """{"data":{"comments":[]}}""")
dataResolver(project).countByTable("_RelayId").await should be(1)

ifConnectorIsActive { dataResolver(project).countByTable("_RelayId").await should be(1) }
}

"a one to many relation" should "be deletable by any unique argument through a nested mutation" in {
Expand Down Expand Up @@ -745,8 +744,7 @@ class NestedDeleteMutationInsideUpdateSpec extends FlatSpec with Matchers with A

val query = server.query("""{ comments { id }}""", project)
mustBeEqual(query.toString, """{"data":{"comments":[]}}""")
dataResolver(project).countByTable("_RelayId").await should be(1)

ifConnectorIsActive { dataResolver(project).countByTable("_RelayId").await should be(1) }
}

"a many to one relation" should "be deletable by id through a nested mutation" in {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ class NestedUpsertMutationInsideUpdateSpec extends FlatSpec with Matchers with A

dataResolver(project).countByTable("Parent").await should be(1)
dataResolver(project).countByTable("Child").await should be(2)
dataResolver(project).countByTable("_RelayId").await should be(3)
dataResolver(project).countByTable("_ParentToChild").await should be(2)
ifConnectorIsActive { dataResolver(project).countByTable("_RelayId").await should be(3) }
}

"a PM to C1! relation with a child already in a relation" should "work with update" in {
Expand Down Expand Up @@ -112,8 +112,8 @@ class NestedUpsertMutationInsideUpdateSpec extends FlatSpec with Matchers with A

dataResolver(project).countByTable("Parent").await should be(1)
dataResolver(project).countByTable("Child").await should be(1)
dataResolver(project).countByTable("_RelayId").await should be(2)
dataResolver(project).countByTable("_ParentToChild").await should be(1)
ifConnectorIsActive { dataResolver(project).countByTable("_RelayId").await should be(2) }
}

"a PM to C1 relation with the parent already in a relation" should "work through a nested mutation by unique for create" in {
Expand Down Expand Up @@ -168,8 +168,8 @@ class NestedUpsertMutationInsideUpdateSpec extends FlatSpec with Matchers with A

dataResolver(project).countByTable("Parent").await should be(1)
dataResolver(project).countByTable("Child").await should be(3)
dataResolver(project).countByTable("_RelayId").await should be(4)
dataResolver(project).countByTable("_ParentToChild").await should be(3)
ifConnectorIsActive { dataResolver(project).countByTable("_RelayId").await should be(4) }
}

"a PM to C1 relation with the parent already in a relation" should "work through a nested mutation by unique for update" in {
Expand Down Expand Up @@ -224,8 +224,8 @@ class NestedUpsertMutationInsideUpdateSpec extends FlatSpec with Matchers with A

dataResolver(project).countByTable("Parent").await should be(1)
dataResolver(project).countByTable("Child").await should be(2)
dataResolver(project).countByTable("_RelayId").await should be(3)
dataResolver(project).countByTable("_ParentToChild").await should be(2)
ifConnectorIsActive { dataResolver(project).countByTable("_RelayId").await should be(3) }
}

"a PM to CM relation with the children already in a relation" should "work through a nested mutation by unique for update" in {
Expand Down Expand Up @@ -281,8 +281,8 @@ class NestedUpsertMutationInsideUpdateSpec extends FlatSpec with Matchers with A

dataResolver(project).countByTable("Parent").await should be(1)
dataResolver(project).countByTable("Child").await should be(2)
dataResolver(project).countByTable("_RelayId").await should be(3)
dataResolver(project).countByTable("_ChildToParent").await should be(2)
ifConnectorIsActive { dataResolver(project).countByTable("_RelayId").await should be(3) }
}

"a PM to CM relation with the children already in a relation" should "work through a nested mutation by unique for create" in {
Expand Down Expand Up @@ -338,8 +338,8 @@ class NestedUpsertMutationInsideUpdateSpec extends FlatSpec with Matchers with A

dataResolver(project).countByTable("Parent").await should be(1)
dataResolver(project).countByTable("Child").await should be(3)
dataResolver(project).countByTable("_RelayId").await should be(4)
dataResolver(project).countByTable("_ChildToParent").await should be(3)
ifConnectorIsActive { dataResolver(project).countByTable("_RelayId").await should be(4) }
}

"a one to many relation" should "be upsertable by id through a nested mutation" in {
Expand Down
Loading

0 comments on commit 5b926a4

Please sign in to comment.