1package cache
2
3import (
4 "testing"
5
6 "github.com/stretchr/testify/assert"
7)
8
9func TestTitleFilter(t *testing.T) {
10 tests := []struct {
11 name string
12 title string
13 query string
14 match bool
15 }{
16 {name: "complete match", title: "hello world", query: "hello world", match: true},
17 {name: "partial match", title: "hello world", query: "hello", match: true},
18 {name: "no match", title: "hello world", query: "foo", match: false},
19 {name: "cased title", title: "Hello World", query: "hello", match: true},
20 {name: "cased query", title: "hello world", query: "Hello", match: true},
21
22 // Those following tests should work eventually but are left for a future iteration.
23
24 // {name: "cased accents", title: "ÑOÑO", query: "ñoño", match: true},
25 // {name: "natural language matching", title: "Århus", query: "Aarhus", match: true},
26 }
27 for _, tt := range tests {
28 t.Run(tt.name, func(t *testing.T) {
29 filter := TitleFilter(tt.query)
30 excerpt := &BugExcerpt{Title: tt.title}
31 assert.Equal(t, tt.match, filter(excerpt, nil))
32 })
33 }
34}