Skip to content

Commit

Permalink
Add negative tests
Browse files Browse the repository at this point in the history
  • Loading branch information
all-seeing-code committed Dec 6, 2022
1 parent 3b6f98c commit f2e8981
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion query/query1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2571,7 +2571,7 @@ func TestExpandAll_empty_panic(t *testing.T) {
require.JSONEq(t, `{"data":{"me":[]}}`, js)
}

func TestMatchFuncWithAfter(t *testing.T) {
func TestMatchFuncWithAfterWithValidUid(t *testing.T) {
query := `
{
q(func: match(name, Ali, 5), after: 0x2710) {
Expand All @@ -2585,6 +2585,34 @@ func TestMatchFuncWithAfter(t *testing.T) {
require.JSONEq(t, `{"data": {"q": [{"name": "Alice", "uid": "0x2712"}, {"name": "Alice", "uid": "0x2714"}]}}`, js)
}

func TestMatchFuncWithAfterWithInvalidUid(t *testing.T) {
query := `
{
q(func: match(name, Ali, 5), after: -1) {
uid
name
}
}
`
_, err := processQuery(context.Background(), t, query)
require.Error(t, err)
require.Contains(t, err.Error(), "parsing \"-1\": invalid syntax")
}

func TestMatchFuncWithAfterWithLastUid(t *testing.T) {
query := `
{
q(func: match(name, Ali, 5), after: 0x2714) {
uid
name
}
}
`

js := processQueryNoErr(t, query)
require.JSONEq(t, `{"data": {"q":[] } }`, js)
}

func TestCompareFuncWithAfter(t *testing.T) {
query := `
{
Expand Down

0 comments on commit f2e8981

Please sign in to comment.