Skip to content

Commit

Permalink
v3_5_experimental: add test scenerios
Browse files Browse the repository at this point in the history
  • Loading branch information
yasminvalim committed Feb 2, 2024
1 parent 4008b9e commit a32d127
Showing 1 changed file with 80 additions and 1 deletion.
81 changes: 80 additions & 1 deletion config/v3_5_experimental/types/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,55 @@ func TestConfigValidation(t *testing.T) {
out: errors.ErrPathConflictsSystemd,
at: path.New("json", "storage", "links", 0, "path"),
},
// test 6: non-conflicting scenarios

// test 6: file path conflicts with another file path, should error
{
in: Config{
Storage: Storage{
Files: []File{
{Node: Node{Path: "/foo/bar"}},
{Node: Node{Path: "/foo/bar/baz"}},
},
},
},
out: errors.ErrPathConflictsParentDir,
at: path.New("json", "storage", "files", 1, "path"),
},

// test 7: file path conflicts with link path, should error
{
in: Config{
Storage: Storage{
Files: []File{
{Node: Node{Path: "/foo/bar"}},
},
Links: []Link{
{Node: Node{Path: "/foo/bar/baz"}},
},
},
},
out: errors.ErrPathConflictsParentDir,
at: path.New("json", "storage", "links", 0, "path"),
},

// test 8: file path conflicts with directory path, should error
{
in: Config{
Storage: Storage{
Files: []File{
{Node: Node{Path: "/foo/bar"}},
{Node: Node{Path: "/foo/bar"}},
},
Directories: []Directory{
{Node: Node{Path: "/foo/bar/baz"}},
},
},
},
out: errors.ErrPathConflictsParentDir,
at: path.New("json", "storage", "directories", 0, "path"),
},

// test 9: non-conflicting scenarios with systemd unit and systemd dropin file, should not error
{
in: Config{
Storage: Storage{
Expand Down Expand Up @@ -248,7 +296,38 @@ func TestConfigValidation(t *testing.T) {
},
},
},

// test 10: non-conflicting scenarios with same parent directory, should not error
{
in: Config{
Storage: Storage{
Files: []File{
{Node: Node{Path: "/foo/bar"}},
{Node: Node{Path: "/foo/bar/baz"}},
},
Directories: []Directory{
{Node: Node{Path: "/foo/bar"}},
},
},
},
},
// test 11: non-conflicting scenarios with a link, should not error
{
in: Config{
Storage: Storage{
Files: []File{
{Node: Node{Path: "/foo/bar"}},
},
Links: []Link{
{Node: Node{Path: "/baz/qux"}},
},
},
},
out: errors.ErrPathConflictsParentDir,
at: path.New("json", "storage", "links", 0, "path"),
},
}

for i, test := range tests {
r := test.in.Validate(path.New("json"))
expected := report.Report{}
Expand Down

0 comments on commit a32d127

Please sign in to comment.