aboutsummaryrefslogtreecommitdiffstats
path: root/query/lexer_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'query/lexer_test.go')
-rw-r--r--query/lexer_test.go28
1 files changed, 19 insertions, 9 deletions
diff --git a/query/lexer_test.go b/query/lexer_test.go
index 59f17dec..6ef679d2 100644
--- a/query/lexer_test.go
+++ b/query/lexer_test.go
@@ -3,7 +3,7 @@ package query
import (
"testing"
- "github.com/stretchr/testify/assert"
+ "github.com/stretchr/testify/require"
)
func TestTokenize(t *testing.T) {
@@ -37,6 +37,14 @@ func TestTokenize(t *testing.T) {
{`key:'value value`, nil},
{`key:value value'`, nil},
+ // sub-qualifier positive testing
+ {`key:subkey:"value:value"`, []token{newTokenKVV("key", "subkey", "value:value")}},
+
+ // sub-qualifier negative testing
+ {`key:subkey:value:value`, nil},
+ {`key:subkey:`, nil},
+ {`key:subkey:"value`, nil},
+
// full text search
{"search", []token{newTokenSearch("search")}},
{"search more terms", []token{
@@ -51,13 +59,15 @@ func TestTokenize(t *testing.T) {
}
for _, tc := range tests {
- tokens, err := tokenize(tc.input)
- if tc.tokens == nil {
- assert.Error(t, err)
- assert.Nil(t, tokens)
- } else {
- assert.NoError(t, err)
- assert.Equal(t, tc.tokens, tokens)
- }
+ t.Run(tc.input, func(t *testing.T) {
+ tokens, err := tokenize(tc.input)
+ if tc.tokens == nil {
+ require.Error(t, err)
+ require.Nil(t, tokens)
+ } else {
+ require.NoError(t, err)
+ require.Equal(t, tc.tokens, tokens)
+ }
+ })
}
}