forked from gobuffalo/packr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
walk_test.go
55 lines (49 loc) · 1.08 KB
/
walk_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
package packr
import (
"testing"
"github.com/stretchr/testify/require"
)
func Test_Box_Walk_Physical(t *testing.T) {
r := require.New(t)
count := 0
err := testBox.Walk(func(path string, f File) error {
count++
return nil
})
r.NoError(err)
r.Equal(3, count)
}
func Test_Box_Walk_Virtual(t *testing.T) {
r := require.New(t)
count := 0
err := virtualBox.Walk(func(path string, f File) error {
count++
return nil
})
r.NoError(err)
r.Equal(4, count)
}
func Test_Box_WalkPrefix_Physical(t *testing.T) {
r := require.New(t)
var files []string
b := NewBox("../packr/fixtures")
err := b.WalkPrefix("foo/", func(path string, f File) error {
files = append(files, path)
return nil
})
r.NoError(err)
r.Equal(2, len(files))
mustHave := osPaths("foo/a.txt", "foo/bar/b.txt")
r.Equal(mustHave, files)
}
func Test_Box_WalkPrefix_Virtual(t *testing.T) {
r := require.New(t)
var files []string
err := virtualBox.WalkPrefix("d", func(path string, f File) error {
files = append(files, path)
return nil
})
r.NoError(err)
r.Equal(1, len(files))
r.Equal([]string{"d/a"}, files)
}