diff options
author | Michael Muré <batolettre@gmail.com> | 2021-02-27 20:39:27 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-27 20:39:27 +0100 |
commit | 22cc4cc043370bac945f92ecf343025ce7fdfe33 (patch) | |
tree | a0162d685c22d274dd4e5916d8cf46136c7dc0ea /query/lexer_test.go | |
parent | 10a259b6823e1234e5add1ee62935f259c39f803 (diff) | |
parent | fab626a7a663a8fa6ef27848bb63e91af812ab8c (diff) | |
download | git-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.go | 28 |
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) + } + }) } } |