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
|
diff --git a/overlay_test.go b/overlay_test.go
index 2992095d9383a209fd4a734b9914be20dc51c00a..07ec8d203d4ec7feb418e99987c7f6938d9820e8 100644
--- a/overlay_test.go
+++ b/overlay_test.go
@@ -3,6 +3,7 @@
import (
"embed"
"io"
+ "io/fs"
"os"
"strings"
"testing"
@@ -59,6 +60,48 @@ t.Logf("fs did not match:\n\tgot: %s\n\texpected: %s\n", string(contents), tc.Expected)
t.FailNow()
}
})
+ }
+}
+
+func TestWalk(t *testing.T) {
+ expected := []string{"test1.txt", "test2.txt"}
+
+ x, err := New("_test/disk", embedded, WithSub("_test/embed"), WithCaching(false))
+ if err != nil {
+ t.Log(err)
+ t.FailNow()
+ }
+
+ found := make([]string, 0)
+ if err := fs.WalkDir(x, ".", func(walkPath string, walkEntry fs.DirEntry, walkErr error) error {
+ if walkErr != nil {
+ return walkErr
+ }
+
+ if walkEntry.IsDir() {
+ return nil
+ }
+
+ found = append(found, walkEntry.Name())
+
+ return nil
+ }); err != nil {
+ t.Log(err)
+ t.FailNow()
+ }
+
+ for _, e := range expected {
+ exists := false
+ for _, f := range found {
+ if e == f {
+ exists = true
+ break
+ }
+ }
+ if !exists {
+ t.Logf("could not find %s in %s\n", e, found)
+ t.Fail()
+ }
}
}
|