MCPcopy
hub / github.com/syncthing/syncthing / TestWalkSub

Function TestWalkSub

lib/scanner/walk_test.go:92–125  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

90}
91
92func TestWalkSub(t *testing.T) {
93 testFs := newTestFs()
94 ignores := ignore.New(testFs)
95 err := ignores.Load(".stignore")
96 if err != nil {
97 t.Fatal(err)
98 }
99
100 cfg, cancel := testConfig()
101 defer cancel()
102 cfg.Subs = []string{"dir2"}
103 cfg.Matcher = ignores
104 fchan := Walk(context.TODO(), cfg)
105 var files []protocol.FileInfo
106 for f := range fchan {
107 if f.Err != nil {
108 t.Errorf("Error while scanning %v: %v", f.Err, f.Path)
109 }
110 files = append(files, f.File)
111 }
112
113 // The directory contains two files, where one is ignored from a higher
114 // level. We should see only the directory and one of the files.
115
116 if len(files) != 2 {
117 t.Fatalf("Incorrect length %d != 2", len(files))
118 }
119 if files[0].Name != "dir2" {
120 t.Errorf("Incorrect file %v != dir2", files[0])
121 }
122 if files[1].Name != filepath.Join("dir2", "cfile") {
123 t.Errorf("Incorrect file %v != dir2/cfile", files[1])
124 }
125}
126
127func TestWalk(t *testing.T) {
128 testFs := newTestFs()

Callers

nothing calls this directly

Calls 6

NewFunction · 0.92
newTestFsFunction · 0.85
testConfigFunction · 0.85
WalkFunction · 0.85
FatalMethod · 0.80
LoadMethod · 0.45

Tested by

no test coverage detected