Skip to content

Commit 1d4720e

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

File tree

1 file changed

+78
-1
lines changed

1 file changed

+78
-1
lines changed

config/v3_5_experimental/types/config_test.go

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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 with systemd unit and systemd dropin file, should not error
187234
{
188235
in: Config{
189236
Storage: Storage{
@@ -248,7 +295,37 @@ func TestConfigValidation(t *testing.T) {
248295
},
249296
},
250297
},
298+
299+
// test 10: non-conflicting scenarios with same parent directory, should not error
300+
{
301+
in: Config{
302+
Storage: Storage{
303+
Files: []File{
304+
{Node: Node{Path: "/foo/bar/baz"}},
305+
},
306+
Directories: []Directory{
307+
{Node: Node{Path: "/foo/bar"}},
308+
},
309+
},
310+
},
311+
},
312+
// test 11: non-conflicting scenarios with a link, should not error
313+
{
314+
in: Config{
315+
Storage: Storage{
316+
Files: []File{
317+
{Node: Node{Path: "/foo/bar"}},
318+
},
319+
Links: []Link{
320+
{Node: Node{Path: "/baz/qux"}},
321+
},
322+
},
323+
},
324+
out: errors.ErrPathConflictsParentDir,
325+
at: path.New("json", "storage", "links", 0, "path"),
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)