Skip to content

Commit

Permalink
test: Add tests for grouping by undefined value (sourcenetwork#543)
Browse files Browse the repository at this point in the history
Add tests for grouping by undefined value
  • Loading branch information
AndrewSisley authored Jun 21, 2022
1 parent 6ac9428 commit db62dae
Showing 1 changed file with 86 additions and 0 deletions.
86 changes: 86 additions & 0 deletions tests/integration/query/simple/with_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,3 +457,89 @@ func TestQuerySimpleWithGroupByBooleanThenNumber(t *testing.T) {

executeTestCase(t, test)
}

func TestQuerySimpleWithGroupByNumberOnUndefined(t *testing.T) {
test := testUtils.QueryTestCase{
Description: "Simple query with group by number, no children, undefined group value",
Query: `query {
users(groupBy: [Age]) {
Age
}
}`,
Docs: map[int][]string{
0: {
`{
"Name": "John",
"Age": 32
}`,
`{
"Name": "Bob"
}`,
`{
"Name": "Alice"
}`,
},
},
Results: []map[string]interface{}{
{
"Age": nil,
},
{
"Age": uint64(32),
},
},
}

executeTestCase(t, test)
}

func TestQuerySimpleWithGroupByNumberOnUndefinedWithChildren(t *testing.T) {
test := testUtils.QueryTestCase{
Description: "Simple query with group by number, with children, undefined group value",
Query: `query {
users(groupBy: [Age]) {
Age
_group {
Name
}
}
}`,
Docs: map[int][]string{
0: {
`{
"Name": "John",
"Age": 32
}`,
`{
"Name": "Bob"
}`,
`{
"Name": "Alice"
}`,
},
},
Results: []map[string]interface{}{
{
"Age": nil,
"_group": []map[string]interface{}{
{
"Name": "Bob",
},
{
"Name": "Alice",
},
},
},
{
"Age": uint64(32),
"_group": []map[string]interface{}{
{
"Name": "John",
},
},
},
},
}

executeTestCase(t, test)
}

0 comments on commit db62dae

Please sign in to comment.