Files
yay/pkg/query/query_builder_search_test.go
github-actions[bot] 9ae45b9b39 test(query): normalize matcher inputs in unit test (#2942)
test(query): normalize matcher inputs in unit test
2026-08-07 12:05:05 +09:00

53 lines
974 B
Go

//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, normalizeSearchTerms(test.terms)))
})
}
}