-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
66ae0a4
commit a2f7807
Showing
3 changed files
with
100 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2022 Democratized Data Foundation | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package simple | ||
|
||
import ( | ||
"testing" | ||
|
||
testUtils "github.com/sourcenetwork/defradb/tests/integration" | ||
) | ||
|
||
func TestQuerySimpleWithCountWithFilter(t *testing.T) { | ||
test := testUtils.QueryTestCase{ | ||
Description: "Simple query, count with filter", | ||
Query: `query { | ||
_count(users: {filter: {Age: {_gt: 26}}}) | ||
}`, | ||
Docs: map[int][]string{ | ||
0: { | ||
`{ | ||
"Name": "John", | ||
"Age": 21 | ||
}`, | ||
`{ | ||
"Name": "Bob", | ||
"Age": 30 | ||
}`, | ||
`{ | ||
"Name": "Alice", | ||
"Age": 32 | ||
}`, | ||
}, | ||
}, | ||
Results: []map[string]interface{}{ | ||
{ | ||
"_count": 2, | ||
}, | ||
}, | ||
} | ||
|
||
executeTestCase(t, test) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Copyright 2022 Democratized Data Foundation | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
package simple | ||
|
||
import ( | ||
"testing" | ||
|
||
testUtils "github.com/sourcenetwork/defradb/tests/integration" | ||
) | ||
|
||
func TestQuerySimpleWithSumWithFilter(t *testing.T) { | ||
test := testUtils.QueryTestCase{ | ||
Description: "Simple query, sum with filter", | ||
Query: `query { | ||
_sum(users: {field: Age, filter: {Age: {_gt: 26}}}) | ||
}`, | ||
Docs: map[int][]string{ | ||
0: { | ||
`{ | ||
"Name": "John", | ||
"Age": 21 | ||
}`, | ||
`{ | ||
"Name": "Bob", | ||
"Age": 30 | ||
}`, | ||
`{ | ||
"Name": "Alice", | ||
"Age": 32 | ||
}`, | ||
}, | ||
}, | ||
Results: []map[string]interface{}{ | ||
{ | ||
"_sum": int64(62), | ||
}, | ||
}, | ||
} | ||
|
||
executeTestCase(t, test) | ||
} |