MCPcopy
hub / github.com/syncthing/syncthing / TestExcludes

Function TestExcludes

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

Source from the content-addressed store, hash-verified

95}
96
97func TestExcludes(t *testing.T) {
98 testFs := newTestFS()
99
100 stignore := `
101 !iex2
102 !ign1/ex
103 ign1
104 i*2
105 !ign2
106 `
107 pats := New(testFs, WithCache(true))
108 err := pats.Parse(bytes.NewBufferString(stignore), ".stignore")
109 if err != nil {
110 t.Fatal(err)
111 }
112
113 tests := []struct {
114 f string
115 r bool
116 }{
117 {"ign1", true},
118 {"ign2", true},
119 {"ibla2", true},
120 {"iex2", false},
121 {filepath.Join("ign1", "ign"), true},
122 {filepath.Join("ign1", "ex"), false},
123 {filepath.Join("ign1", "iex2"), false},
124 {filepath.Join("iex2", "ign"), false},
125 {filepath.Join("foo", "bar", "ign1"), true},
126 {filepath.Join("foo", "bar", "ign2"), true},
127 {filepath.Join("foo", "bar", "iex2"), false},
128 }
129
130 for _, tc := range tests {
131 if r := pats.Match(tc.f); r.IsIgnored() != tc.r {
132 t.Errorf("Incorrect match for %s: %v != %v", tc.f, r, tc.r)
133 }
134 }
135}
136
137func TestFlagOrder(t *testing.T) {
138 testFs := newTestFS()

Callers

nothing calls this directly

Calls 7

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

Tested by

no test coverage detected