@@ -183,7 +183,54 @@ func TestConfigValidation(t *testing.T) {
183183 out : errors .ErrPathConflictsSystemd ,
184184 at : path .New ("json" , "storage" , "links" , 0 , "path" ),
185185 },
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+ },
224+ Directories : []Directory {
225+ {Node : Node {Path : "/foo/bar/baz" }},
226+ },
227+ },
228+ },
229+ out : errors .ErrPathConflictsParentDir ,
230+ at : path .New ("json" , "storage" , "directories" , 0 , "path" ),
231+ },
232+
233+ // test 9: non-conflicting scenarios
187234 {
188235 in : Config {
189236 Storage : Storage {
@@ -249,6 +296,7 @@ func TestConfigValidation(t *testing.T) {
249296 },
250297 },
251298 }
299+
252300 for i , test := range tests {
253301 r := test .in .Validate (path .New ("json" ))
254302 expected := report.Report {}
@@ -258,3 +306,32 @@ func TestConfigValidation(t *testing.T) {
258306 }
259307 }
260308}
309+
310+ // // Test 2: Single directory without the file, should not error
311+ // {
312+ // in: Config{
313+ // Storage: Storage{
314+ // Directories: []Directory{
315+ // {Node: Node{Path: "/home/bar/"}},
316+ // },
317+ // Files: []File{
318+ // {Node: Node{Path: "/home/bar"}},
319+ // },
320+ // },
321+ // },
322+ // out: errors.ErrPathConflict,
323+ // },
324+ // // Test 3: Directory and file with correct paths, should not error
325+ // {
326+ // in: Config{
327+ // Storage: Storage{
328+ // Directories: []Directory{
329+ // {Node: Node{Path: "/home/bar/"}},
330+ // },
331+ // Files: []File{
332+ // {Node: Node{Path: "/home/bar/baz"}},
333+ // },
334+ // },
335+ // },
336+ // out: nil,
337+ // },
0 commit comments