aboutsummaryrefslogtreecommitdiffstats
path: root/query/lexer_test.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2021-02-27 20:39:27 +0100
committerGitHub <noreply@github.com>2021-02-27 20:39:27 +0100
commit22cc4cc043370bac945f92ecf343025ce7fdfe33 (patch)
treea0162d685c22d274dd4e5916d8cf46136c7dc0ea /query/lexer_test.go
parent10a259b6823e1234e5add1ee62935f259c39f803 (diff)
parentfab626a7a663a8fa6ef27848bb63e91af812ab8c (diff)
downloadgit-bug-22cc4cc043370bac945f92ecf343025ce7fdfe33.tar.gz
Merge pull request #568 from vmiklos/search-metadata
Add ability to search by arbitrary metadata
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)
+ }
+ })
}
}