From cb61245078a0e8f14e359ed20e0582a695645a08 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Sun, 14 Feb 2021 16:03:51 +0100 Subject: Add ability to search by arbitrary metadata Example: ~/git/git-bug/git-bug ls --metadata github-url=https://github.com/author/myproject/issues/42 or ~/git/git-bug/git-bug ls metadata:github-url:\"https://github.com/author/myproject/issues/42\" Fixes the cmdline part of . --- query/lexer_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'query/lexer_test.go') diff --git a/query/lexer_test.go b/query/lexer_test.go index 59f17dec..4ffb35a0 100644 --- a/query/lexer_test.go +++ b/query/lexer_test.go @@ -37,6 +37,14 @@ func TestTokenize(t *testing.T) { {`key:'value value`, nil}, {`key:value value'`, nil}, + // sub-qualifier posive 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{ -- cgit From fab626a7a663a8fa6ef27848bb63e91af812ab8c Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Sat, 27 Feb 2021 20:31:10 +0100 Subject: query: refactor to reuse the split function for both query and token --- query/lexer_test.go | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'query/lexer_test.go') diff --git a/query/lexer_test.go b/query/lexer_test.go index 4ffb35a0..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,7 +37,7 @@ func TestTokenize(t *testing.T) { {`key:'value value`, nil}, {`key:value value'`, nil}, - // sub-qualifier posive testing + // sub-qualifier positive testing {`key:subkey:"value:value"`, []token{newTokenKVV("key", "subkey", "value:value")}}, // sub-qualifier negative testing @@ -59,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) + } + }) } } -- cgit