From caab26bfda533571d8a7067b4e12c68eb07b20a9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 31 Jul 2026 02:56:18 +0900 Subject: [PATCH] [repo-assist] test(query): cover multi-term search matching (#2938) test(query): cover multi-term search matching Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- pkg/query/query_builder_search_test.go | 52 ++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 pkg/query/query_builder_search_test.go diff --git a/pkg/query/query_builder_search_test.go b/pkg/query/query_builder_search_test.go new file mode 100644 index 00000000..b47f9b0e --- /dev/null +++ b/pkg/query/query_builder_search_test.go @@ -0,0 +1,52 @@ +//go:build !integration + +package query + +import ( + "testing" + + "github.com/Jguer/aur" + "github.com/stretchr/testify/assert" +) + +func TestMatchesSearch(t *testing.T) { + t.Parallel() + + pkg := &aur.Pkg{ + Name: "Linux", + Description: "The Linux kernel and modules", + } + + tests := []struct { + name string + terms []string + want bool + }{ + { + name: "all terms match name or description", + terms: []string{"linux", "MODULES"}, + want: true, + }, + { + name: "missing term rejects package", + terms: []string{"linux", "wayland"}, + want: false, + }, + { + name: "symbol term does not bypass text matching", + terms: []string{"wayland", "✓"}, + want: false, + }, + { + name: "symbol term is ignored alongside matching text", + terms: []string{"kernel", "✓"}, + want: true, + }, + } + + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + assert.Equal(t, test.want, matchesSearch(pkg, test.terms)) + }) + } +}