-
Notifications
You must be signed in to change notification settings - Fork 0
/
walk_test.go
70 lines (60 loc) · 1.3 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package vfs
import (
"os"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Walk", func() {
var fs FileSystem
BeforeEach(func() {
fs = Mem(
Dir("integration",
Dir("directory",
Dir("sub_directory"),
File("child.txt", []byte("hi, child")),
),
Dir("empty_directory"),
File("root.txt", []byte("hi, root")),
),
Dir("tree-two",
Dir("directory",
Dir("sub_directory"),
File("child.txt", []byte("hi, child")),
),
Dir("empty_directory"),
File("root.txt", []byte("hi, root")),
),
Dir("tree-3",
Dir("1",
Dir("2",
Dir("6",
File("8.txt", []byte("yo")),
),
Dir("3",
Dir("4",
File("5.txt", []byte("yo")),
),
),
),
),
),
)
})
It("should call walkFn for each directory & file", func() {
count := 0
err := Walk(fs, func(fs FileSystem, info os.FileInfo, err error) error {
count = count + 1
return err
})
Expect(err).NotTo(HaveOccurred())
Expect(count).To(Equal(20))
})
It("should be able to Stat each file by name and subtree", func() {
err := Walk(fs, func(tree FileSystem, info os.FileInfo, err error) error {
_, err = tree.Stat(info.Name())
Expect(err).NotTo(HaveOccurred())
return nil
})
Expect(err).NotTo(HaveOccurred())
})
})