diff options
author | 6543 <m.huber@kithara.com> | 2024-03-16 14:19:41 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-16 13:19:41 +0000 |
commit | c6e5ec51bd5d2d3ede30b7506e7cc47f18a49ca8 (patch) | |
tree | db252a3c927a2127ce2286933ceb9cfe0af5dfb6 /modules/indexer/issues/meilisearch/meilisearch_test.go | |
parent | 3cd64949ae1402a4ff45fba0a27c4acca1c5aead (diff) | |
download | gitea-c6e5ec51bd5d2d3ede30b7506e7cc47f18a49ca8.tar.gz gitea-c6e5ec51bd5d2d3ede30b7506e7cc47f18a49ca8.zip |
Meilisearch double quote on "match" query (#29740)
make `nonFuzzyWorkaround` unessesary
cc @Kerollmops
Diffstat (limited to 'modules/indexer/issues/meilisearch/meilisearch_test.go')
-rw-r--r-- | modules/indexer/issues/meilisearch/meilisearch_test.go | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/modules/indexer/issues/meilisearch/meilisearch_test.go b/modules/indexer/issues/meilisearch/meilisearch_test.go index ecce704236..4666df136a 100644 --- a/modules/indexer/issues/meilisearch/meilisearch_test.go +++ b/modules/indexer/issues/meilisearch/meilisearch_test.go @@ -53,11 +53,10 @@ func TestMeilisearchIndexer(t *testing.T) { tests.TestIndexer(t, indexer) } -func TestNonFuzzyWorkaround(t *testing.T) { - // get unexpected return - _, err := nonFuzzyWorkaround(&meilisearch.SearchResponse{ +func TestConvertHits(t *testing.T) { + _, err := convertHits(&meilisearch.SearchResponse{ Hits: []any{"aa", "bb", "cc", "dd"}, - }, "bowling", false) + }) assert.ErrorIs(t, err, ErrMalformedResponse) validResponse := &meilisearch.SearchResponse{ @@ -82,14 +81,15 @@ func TestNonFuzzyWorkaround(t *testing.T) { }, }, } - - // nonFuzzy - hits, err := nonFuzzyWorkaround(validResponse, "bowling", false) - assert.NoError(t, err) - assert.EqualValues(t, []internal.Match{{ID: 11}, {ID: 22}}, hits) - - // fuzzy - hits, err = nonFuzzyWorkaround(validResponse, "bowling", true) + hits, err := convertHits(validResponse) assert.NoError(t, err) assert.EqualValues(t, []internal.Match{{ID: 11}, {ID: 22}, {ID: 33}}, hits) } + +func TestDoubleQuoteKeyword(t *testing.T) { + assert.EqualValues(t, "", doubleQuoteKeyword("")) + assert.EqualValues(t, `"a" "b" "c"`, doubleQuoteKeyword("a b c")) + assert.EqualValues(t, `"a" "d" "g"`, doubleQuoteKeyword("a d g")) + assert.EqualValues(t, `"a" "d" "g"`, doubleQuoteKeyword("a d g")) + assert.EqualValues(t, `"a" "d" "g"`, doubleQuoteKeyword(`a "" "d" """g`)) +} |