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 1d4720e
Showing 1 changed file with 78 additions and 1 deletion.
79 changes: 78 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,54 @@ 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"}},
},
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 +295,37 @@ 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/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 1d4720e

Please sign in to comment.