@@ -183,7 +183,55 @@ func TestConfigValidation(t *testing.T) {
183
183
out : errors .ErrPathConflictsSystemd ,
184
184
at : path .New ("json" , "storage" , "links" , 0 , "path" ),
185
185
},
186
- // test 6: non-conflicting scenarios
186
+
187
+ // test 6: file path conflicts with another file path, should error
188
+ {
189
+ in : Config {
190
+ Storage : Storage {
191
+ Files : []File {
192
+ {Node : Node {Path : "/foo/bar" }},
193
+ {Node : Node {Path : "/foo/bar/baz" }},
194
+ },
195
+ },
196
+ },
197
+ out : errors .ErrPathConflictsParentDir ,
198
+ at : path .New ("json" , "storage" , "files" , 1 , "path" ),
199
+ },
200
+
201
+ // test 7: file path conflicts with link path, should error
202
+ {
203
+ in : Config {
204
+ Storage : Storage {
205
+ Files : []File {
206
+ {Node : Node {Path : "/foo/bar" }},
207
+ },
208
+ Links : []Link {
209
+ {Node : Node {Path : "/foo/bar/baz" }},
210
+ },
211
+ },
212
+ },
213
+ out : errors .ErrPathConflictsParentDir ,
214
+ at : path .New ("json" , "storage" , "links" , 0 , "path" ),
215
+ },
216
+
217
+ // test 8: file path conflicts with directory path, should error
218
+ {
219
+ in : Config {
220
+ Storage : Storage {
221
+ Files : []File {
222
+ {Node : Node {Path : "/foo/bar" }},
223
+ {Node : Node {Path : "/foo/bar" }},
224
+ },
225
+ Directories : []Directory {
226
+ {Node : Node {Path : "/foo/bar/baz" }},
227
+ },
228
+ },
229
+ },
230
+ out : errors .ErrPathConflictsParentDir ,
231
+ at : path .New ("json" , "storage" , "directories" , 0 , "path" ),
232
+ },
233
+
234
+ // test 9: non-conflicting scenarios with systemd unit and systemd dropin file, should not error
187
235
{
188
236
in : Config {
189
237
Storage : Storage {
@@ -248,7 +296,36 @@ func TestConfigValidation(t *testing.T) {
248
296
},
249
297
},
250
298
},
299
+
300
+ // test 10: non-conflicting scenarios with same parent directory, should not error
301
+ {
302
+ in : Config {
303
+ Storage : Storage {
304
+ Files : []File {
305
+ {Node : Node {Path : "/foo/bar" }},
306
+ {Node : Node {Path : "/foo/bar/baz" }},
307
+ },
308
+ Directories : []Directory {
309
+ {Node : Node {Path : "/foo/bar" }},
310
+ },
311
+ },
312
+ },
313
+ },
314
+ // test 11: non-conflicting scenarios with a link, should not error
315
+ {
316
+ in : Config {
317
+ Storage : Storage {
318
+ Files : []File {
319
+ {Node : Node {Path : "/foo/bar" }},
320
+ },
321
+ Links : []Link {
322
+ {Node : Node {Path : "/baz/qux" }},
323
+ },
324
+ },
325
+ },
326
+ },
251
327
}
328
+
252
329
for i , test := range tests {
253
330
r := test .in .Validate (path .New ("json" ))
254
331
expected := report.Report {}
0 commit comments