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 Jan 30, 2024
1 parent 4008b9e commit da6f0d3
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
{
in: Config{
Storage: Storage{
Expand Down Expand Up @@ -249,6 +296,7 @@ func TestConfigValidation(t *testing.T) {
},
},
}

for i, test := range tests {
r := test.in.Validate(path.New("json"))
expected := report.Report{}
Expand All @@ -258,3 +306,32 @@ func TestConfigValidation(t *testing.T) {
}
}
}

// // Test 2: Single directory without the file, should not error
// {
// in: Config{
// Storage: Storage{
// Directories: []Directory{
// {Node: Node{Path: "/home/bar/"}},
// },
// Files: []File{
// {Node: Node{Path: "/home/bar"}},
// },
// },
// },
// out: errors.ErrPathConflict,
// },
// // Test 3: Directory and file with correct paths, should not error
// {
// in: Config{
// Storage: Storage{
// Directories: []Directory{
// {Node: Node{Path: "/home/bar/"}},
// },
// Files: []File{
// {Node: Node{Path: "/home/bar/baz"}},
// },
// },
// },
// out: nil,
// },

0 comments on commit da6f0d3

Please sign in to comment.