MCPcopy
hub / github.com/syncthing/syncthing / TestIgnore

Function TestIgnore

lib/ignore/ignore_test.go:52–95  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

50}
51
52func TestIgnore(t *testing.T) {
53 testFs := newTestFS()
54
55 pats := New(testFs, WithCache(true))
56 err := pats.Load(".stignore")
57 if err != nil {
58 t.Fatal(err)
59 }
60
61 tests := []struct {
62 f string
63 r bool
64 }{
65 {"afile", false},
66 {"bfile", true},
67 {"cfile", false},
68 {"dfile", false},
69 {"efile", true},
70 {"ffile", true},
71
72 {"dir1", false},
73 {filepath.Join("dir1", "cfile"), true},
74 {filepath.Join("dir1", "dfile"), false},
75 {filepath.Join("dir1", "efile"), true},
76 {filepath.Join("dir1", "ffile"), false},
77
78 {"dir2", false},
79 {filepath.Join("dir2", "cfile"), false},
80 {filepath.Join("dir2", "dfile"), true},
81 {filepath.Join("dir2", "efile"), true},
82 {filepath.Join("dir2", "ffile"), false},
83
84 {filepath.Join("dir3"), true},
85 {filepath.Join("dir3", "afile"), true},
86
87 {"lost+found", true},
88 }
89
90 for i, tc := range tests {
91 if r := pats.Match(tc.f); r.IsIgnored() != tc.r {
92 t.Errorf("Incorrect ignoreFile() #%d (%s); E: %v, A: %v", i, tc.f, tc.r, r)
93 }
94 }
95}
96
97func TestExcludes(t *testing.T) {
98 testFs := newTestFS()

Callers

nothing calls this directly

Calls 7

newTestFSFunction · 0.85
WithCacheFunction · 0.85
FatalMethod · 0.80
NewFunction · 0.70
MatchMethod · 0.65
LoadMethod · 0.45
IsIgnoredMethod · 0.45

Tested by

no test coverage detected