Skip to content

Commit

Permalink
test: split filters into its separate functions
Browse files Browse the repository at this point in the history
  • Loading branch information
cybersiddhu committed Aug 23, 2022
1 parent 1a7543f commit 3e1a675
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion query/query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func TestParseFilterString(t *testing.T) {
assert.Len(b, 0, "should have empty slice since regex doesn't match string")
}

func TestQualifiedAQLStatement(t *testing.T) {
func TestQualifiedEqualFilter(t *testing.T) {
t.Parallel()
assert := require.New(t)
dbh, cstr := setupTestArango(assert)
Expand All @@ -146,6 +146,13 @@ func TestQualifiedAQLStatement(t *testing.T) {
)
err = dbh.ValidateQ(genFullQualifiedStmt(nqa, "fizz", cstr))
assert.NoError(err, "should not have any invalid AQL query")
}

func TestQualifiedSubstringFilter(t *testing.T) {
t.Parallel()
assert := require.New(t)
dbh, cstr := setupTestArango(assert)
defer cleanupAfterEach(assert, dbh)
// test item substring for quotes
qf, err := ParseFilterString("label=~GWDI")
assert.NoError(err, "should not return any parsing error")
Expand All @@ -161,6 +168,13 @@ func TestQualifiedAQLStatement(t *testing.T) {
)
err = dbh.ValidateQ(genFullQualifiedStmt(qsa, "v", cstr))
assert.NoError(err, "should not have any invalid AQL query")
}

func TestQualifiedDateFilter(t *testing.T) {
t.Parallel()
assert := require.New(t)
dbh, cstr := setupTestArango(assert)
defer cleanupAfterEach(assert, dbh)
// test date equals
df, err := ParseFilterString("created_at$==2019,created_at$==2018")
assert.NoError(err, "should not return any parsing error")
Expand All @@ -175,6 +189,13 @@ func TestQualifiedAQLStatement(t *testing.T) {
)
err = dbh.ValidateQ(genFullQualifiedStmt(dfl, "foo", cstr))
assert.NoError(err, "should not have any invalid AQL query")
}

func TestQualifiedArrayFilter(t *testing.T) {
t.Parallel()
assert := require.New(t)
dbh, cstr := setupTestArango(assert)
defer cleanupAfterEach(assert, dbh)
// test item in array equals
af, err := ParseFilterString("sport@==basketball")
assert.NoError(err, "should not return any parsing error")
Expand Down

0 comments on commit 3e1a675

Please sign in to comment.