@@ -21,13 +21,15 @@ func TestScanDir(t *testing.T) {
21
21
"regex_ignore/file6.txt" : 600 ,
22
22
"another_dir/file7.txt" : 700 ,
23
23
"symlink_target.txt" : 800 ,
24
+ "local.tmp" : 0 ,
24
25
}
25
26
26
27
dirs := []string {
27
28
filepath .Join (tempDir , "subdir" ),
28
29
filepath .Join (tempDir , "regex_ignore" ),
29
30
filepath .Join (tempDir , "another_dir" ),
30
31
filepath .Join (tempDir , "empty_dir" ),
32
+ filepath .Join (tempDir , "ignore_dir" ),
31
33
}
32
34
33
35
for _ , dir := range dirs {
@@ -76,6 +78,7 @@ func TestScanDir(t *testing.T) {
76
78
ignoreNames : nil ,
77
79
ignoreRegex : nil ,
78
80
expectedSizes : map [int64 ]int {
81
+ 0 : 1 ,
79
82
100 : 2 , // two files of size 100
80
83
200 : 1 ,
81
84
300 : 1 ,
@@ -93,6 +96,7 @@ func TestScanDir(t *testing.T) {
93
96
ignoreNames : map [string ]struct {}{"ignored_file.txt" : {}},
94
97
ignoreRegex : nil ,
95
98
expectedSizes : map [int64 ]int {
99
+ 0 : 1 ,
96
100
100 : 2 ,
97
101
200 : 1 ,
98
102
400 : 2 ,
@@ -108,6 +112,7 @@ func TestScanDir(t *testing.T) {
108
112
ignoreNames : nil ,
109
113
ignoreRegex : regexp .MustCompile (`regex_ignore` ),
110
114
expectedSizes : map [int64 ]int {
115
+ 0 : 1 ,
111
116
100 : 2 ,
112
117
200 : 1 ,
113
118
300 : 1 ,
@@ -124,6 +129,7 @@ func TestScanDir(t *testing.T) {
124
129
ignoreNames : map [string ]struct {}{"ignored_file.txt" : {}},
125
130
ignoreRegex : regexp .MustCompile (`regex_ignore` ),
126
131
expectedSizes : map [int64 ]int {
132
+ 0 : 1 ,
127
133
100 : 2 ,
128
134
200 : 1 ,
129
135
400 : 2 ,
@@ -159,6 +165,41 @@ func TestScanDir(t *testing.T) {
159
165
expectedSizes : map [int64 ]int {},
160
166
expectError : false ,
161
167
},
168
+ {
169
+ name : "Ignore directory" ,
170
+ root : tempDir ,
171
+ ignoreNames : map [string ]struct {}{"ignore_dir" : struct {}{}},
172
+ ignoreRegex : nil ,
173
+ expectedSizes : map [int64 ]int {
174
+ 0 : 1 ,
175
+ 100 : 2 ,
176
+ 200 : 1 ,
177
+ 300 : 1 ,
178
+ 400 : 2 ,
179
+ 500 : 1 ,
180
+ 600 : 1 ,
181
+ 700 : 1 ,
182
+ 800 : 1 ,
183
+ },
184
+ expectError : false ,
185
+ },
186
+ {
187
+ name : "Ignore file by regex" ,
188
+ root : tempDir ,
189
+ ignoreNames : nil ,
190
+ ignoreRegex : regexp .MustCompile (`.*\.tmp$` ),
191
+ expectedSizes : map [int64 ]int {
192
+ 100 : 2 ,
193
+ 200 : 1 ,
194
+ 300 : 1 ,
195
+ 400 : 2 ,
196
+ 500 : 1 ,
197
+ 600 : 1 ,
198
+ 700 : 1 ,
199
+ 800 : 1 ,
200
+ },
201
+ expectError : false ,
202
+ },
162
203
}
163
204
164
205
for _ , tc := range tests {
0 commit comments