Skip to content

Commit

Permalink
test(i): Assert all expected props are returned in tests (#2535)
Browse files Browse the repository at this point in the history
## Relevant issue(s)

Resolves #2435

## Description

Asserts that all expected properties are returned in integration test
queries.
  • Loading branch information
AndrewSisley authored Apr 19, 2024
1 parent 4a75f23 commit f36a43f
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tests/integration/backup/one_to_one/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,8 @@ func TestBackupImport_DoubleRelationshipWithUpdate_NoError(t *testing.T) {
},
},
{
"name": "Game of chains",
"name": "Game of chains",
"author": nil,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ func TestP2PPeerCreateWithNewFieldDocSyncedBeforeReceivingNodeSchemaUpdatedDoesN
{
"Name": "John",
// The email should be returned but it is not
"Email": nil,
},
},
},
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/query/one_to_many/with_cid_doc_id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ func TestQueryOneToManyWithParentUpdateAndFirstCidAndDocID(t *testing.T) {
cid: "bafybeia3qbhebdwssoe5udinpbdj4pntb5wjr77ql7ptzq32howbaxz2cu",
docID: "bae-b9b83269-1f28-5c3b-ae75-3fb4c00d559d"
) {
name
rating
author {
name
Expand Down Expand Up @@ -327,6 +328,7 @@ func TestQueryOneToManyWithParentUpdateAndLastCidAndDocID(t *testing.T) {
cid: "bafybeibqkdnc63xh5k4frs3x3k7z7p6sw4usjrhxd4iusbjj2uhxfjfjcq",
docID: "bae-b9b83269-1f28-5c3b-ae75-3fb4c00d559d"
) {
name
rating
author {
name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func TestQueryOneToManyWithParentGroupByOnRelatedTypeFromManySideUsingAlias(t *t

Request: `query {
Book(groupBy: [author]) {
author_id
_group {
name
rating
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func TestQueryOneToManyWithParentGroupByOnRelatedTypeIDFromManySide(t *testing.T
Description: "One-to-many query with groupBy on related id (from many side).",
Request: `query {
Book(groupBy: [author_id]) {
author_id
_group {
name
rating
Expand Down
1 change: 1 addition & 0 deletions tests/integration/query/simple/with_order_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func TestQuerySimpleWithEmptyOrder(t *testing.T) {
Request: `query {
Users(order: {}) {
Name
Age
}
}`,
Docs: map[int][]string{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func TestSchemaMigrationQueryWithP2PReplicatedDocOnOtherSchemaBranch(t *testing.
Users {
name
phone
verified
}
}
`,
Expand Down
12 changes: 12 additions & 0 deletions tests/integration/utils2.go
Original file line number Diff line number Diff line change
Expand Up @@ -1811,6 +1811,18 @@ func assertRequestResults(

for docIndex, result := range resultantData {
expectedResult := expectedResults[docIndex]

require.Equal(
s.t,
len(expectedResult),
len(result),
fmt.Sprintf(
"%s \n(number of properties for item at index %v don't match)",
s.testCase.Description,
docIndex,
),
)

for field, actualValue := range result {
expectedValue := expectedResult[field]

Expand Down
1 change: 1 addition & 0 deletions tests/integration/view/simple/with_filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func TestView_SimpleWithFilterOnViewAndQuery(t *testing.T) {
query {
UserView(filter: {age: {_eq: 31}}) {
name
age
}
}
`,
Expand Down

0 comments on commit f36a43f

Please sign in to comment.