-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsearchfile_test.go
57 lines (55 loc) · 1.13 KB
/
searchfile_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
package linkedpackage
import (
"reflect"
"testing"
)
func TestSearch(t *testing.T) {
type args struct {
dir string
extensions []string
}
tests := []struct {
name string
args args
want []string
}{
{
name: "empty folder",
args: args{
dir: "testdata/searchtest/empty",
extensions: []string{".js.map"},
},
want: []string{},
},
{
name: "search single folder",
args: args{
dir: "testdata/searchtest/subdir",
extensions: []string{".js.map"},
},
want: []string{
"testdata/searchtest/subdir/test1.js.map",
"testdata/searchtest/subdir/test3.js.map",
},
},
{
name: "search folder recursively",
args: args{
dir: "testdata/searchtest",
extensions: []string{".js.map"},
},
want: []string{
"testdata/searchtest/subdir/test1.js.map",
"testdata/searchtest/subdir/test3.js.map",
"testdata/searchtest/test2.js.map",
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := Search(tt.args.dir, tt.args.extensions...); !reflect.DeepEqual(got, tt.want) {
t.Errorf("Search() = %v, want %v", got, tt.want)
}
})
}
}