Skip to content

Commit a36c760

Browse files
committed
v3_5_experimental: add test scenerios
1 parent 4008b9e commit a36c760

File tree

1 file changed

+78
-1
lines changed

1 file changed

+78
-1
lines changed

config/v3_5_experimental/types/config_test.go

+78-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,55 @@ 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+
{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
187235
{
188236
in: Config{
189237
Storage: Storage{
@@ -248,7 +296,36 @@ func TestConfigValidation(t *testing.T) {
248296
},
249297
},
250298
},
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+
},
251327
}
328+
252329
for i, test := range tests {
253330
r := test.in.Validate(path.New("json"))
254331
expected := report.Report{}

0 commit comments

Comments
 (0)