Skip to content

Commit

Permalink
test: only add table tests for GeneratePath
Browse files Browse the repository at this point in the history
Per offline comments, let's just have the SameContent tests for
GeneratePath, because every other kind of paths are tested indirectly in
slicer_test and setup_test.

Similar to 167a6eb, but do not remove the table tests.
  • Loading branch information
rebornplusplus committed Nov 25, 2024
1 parent af58264 commit 72b7e0b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 70 deletions.
1 change: 0 additions & 1 deletion internal/setup/export_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
package setup

type YAMLPath = yamlPath
type YAMLArch = yamlArch
71 changes: 2 additions & 69 deletions internal/setup/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2241,87 +2241,20 @@ func (s *S) TestParseSliceKey(c *C) {
}
}

var sampleText = "sample"

var yamlPathTests = []struct {
summary string
path1, path2 *setup.YAMLPath
result bool
}{{
summary: "Text path",
path1: &setup.YAMLPath{Text: &sampleText, Mutable: true, Mode: 0644},
path2: &setup.YAMLPath{Text: &sampleText, Mutable: true, Mode: 0644},
result: true,
}, {
summary: "Dir path",
path1: &setup.YAMLPath{Dir: true, Mode: 0755},
path2: &setup.YAMLPath{Dir: true, Mode: 0755},
result: true,
}, {
summary: "Symlink path",
path1: &setup.YAMLPath{Symlink: "foo"},
path2: &setup.YAMLPath{Symlink: "foo"},
result: true,
}, {
summary: "Generate path",
summary: `Same "generate" value`,
path1: &setup.YAMLPath{Generate: setup.GenerateManifest},
path2: &setup.YAMLPath{Generate: setup.GenerateManifest},
result: true,
}, {
summary: "Copy path",
path1: &setup.YAMLPath{Copy: "foo"},
path2: &setup.YAMLPath{Copy: "foo"},
result: true,
}, {
summary: `"arch" is not checked`,
path1: &setup.YAMLPath{Text: nil, Arch: setup.YAMLArch{List: []string{"amd64"}}},
path2: &setup.YAMLPath{Text: nil, Arch: setup.YAMLArch{List: []string{"arm64"}}},
result: true,
}, {
summary: `"until" is not checked`,
path1: &setup.YAMLPath{Copy: "foo", Mutable: true, Until: setup.UntilMutate},
path2: &setup.YAMLPath{Copy: "foo", Mutable: true},
result: true,
}, {
summary: `Empty "text" produces nil pointer`,
path1: &setup.YAMLPath{Text: nil},
path2: &setup.YAMLPath{Text: nil},
result: true,
}, {
summary: `Different "generate" values`,
summary: `Different "generate" value`,
path1: &setup.YAMLPath{Generate: setup.GenerateManifest},
path2: &setup.YAMLPath{Generate: setup.GenerateNone},
result: false,
}, {
summary: `Different "text" pointers`,
path1: &setup.YAMLPath{Text: new(string)},
path2: &setup.YAMLPath{Text: new(string)},
result: false,
}, {
summary: `Different "copy" values`,
path1: &setup.YAMLPath{Copy: "foo"},
path2: &setup.YAMLPath{Copy: "bar"},
result: false,
}, {
summary: `Different "make" (Dir) values`,
path1: &setup.YAMLPath{Dir: true},
path2: &setup.YAMLPath{Dir: false},
result: false,
}, {
summary: `Different "symlink" values`,
path1: &setup.YAMLPath{Symlink: "foo"},
path2: &setup.YAMLPath{Symlink: "bar"},
result: false,
}, {
summary: `Different "mode" values`,
path1: &setup.YAMLPath{Text: nil, Mode: 0644},
path2: &setup.YAMLPath{Text: nil, Mode: 0755},
result: false,
}, {
summary: `Different "mutable" values`,
path1: &setup.YAMLPath{Text: nil, Mutable: true},
path2: &setup.YAMLPath{Text: nil, Mutable: false},
result: false,
}}

func (s *S) TestYAMLPathSameContent(c *C) {
Expand Down

0 comments on commit 72b7e0b

Please sign in to comment.