Skip to content

Commit caab26b

Browse files
[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>
1 parent 63f1627 commit caab26b

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
//go:build !integration
2+
3+
package query
4+
5+
import (
6+
"testing"
7+
8+
"github.com/Jguer/aur"
9+
"github.com/stretchr/testify/assert"
10+
)
11+
12+
func TestMatchesSearch(t *testing.T) {
13+
t.Parallel()
14+
15+
pkg := &aur.Pkg{
16+
Name: "Linux",
17+
Description: "The Linux kernel and modules",
18+
}
19+
20+
tests := []struct {
21+
name string
22+
terms []string
23+
want bool
24+
}{
25+
{
26+
name: "all terms match name or description",
27+
terms: []string{"linux", "MODULES"},
28+
want: true,
29+
},
30+
{
31+
name: "missing term rejects package",
32+
terms: []string{"linux", "wayland"},
33+
want: false,
34+
},
35+
{
36+
name: "symbol term does not bypass text matching",
37+
terms: []string{"wayland", "✓"},
38+
want: false,
39+
},
40+
{
41+
name: "symbol term is ignored alongside matching text",
42+
terms: []string{"kernel", "✓"},
43+
want: true,
44+
},
45+
}
46+
47+
for _, test := range tests {
48+
t.Run(test.name, func(t *testing.T) {
49+
assert.Equal(t, test.want, matchesSearch(pkg, test.terms))
50+
})
51+
}
52+
}

0 commit comments

Comments
 (0)