-
Notifications
You must be signed in to change notification settings - Fork 15
/
search_test.go
86 lines (84 loc) · 1.46 KB
/
search_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package main
import (
"reflect"
"testing"
)
func TestPreParseQuery(t *testing.T) {
type args struct {
args []string
}
tests := []struct {
name string
args args
want []string
want1 string
}{
{
name: "empty",
args: args{
args: []string{},
},
want: []string{},
want1: "",
},
{
name: "no fuzzy",
args: args{
args: []string{"test"},
},
want: []string{"test"},
want1: "",
},
{
name: "single fuzzy",
args: args{
args: []string{"file:test"},
},
want: []string{},
want1: "test",
},
{
name: "single fuzzy alternate",
args: args{
args: []string{"filename:test"},
},
want: []string{},
want1: "test",
},
{
name: "multi fuzzy last wins",
args: args{
args: []string{"file:test", "file:other"},
},
want: []string{},
want1: "other",
},
{
name: "single fuzzy single term",
args: args{
args: []string{"stuff", "file:test"},
},
want: []string{"stuff"},
want1: "test",
},
{
name: "single fuzzy uppercase",
args: args{
args: []string{"FILE:test", "UPPER"},
},
want: []string{"UPPER"},
want1: "test",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
got, got1 := PreParseQuery(tt.args.args)
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("PreParseQuery() got = %v, want %v", got, tt.want)
}
if got1 != tt.want1 {
t.Errorf("PreParseQuery() got1 = %v, want %v", got1, tt.want1)
}
})
}
}