diff --git a/internal/setup/setup_test.go b/internal/setup/setup_test.go index 49ec8e3b..c08bc15f 100644 --- a/internal/setup/setup_test.go +++ b/internal/setup/setup_test.go @@ -2244,49 +2244,90 @@ func (s *S) TestParseSliceKey(c *C) { var sampleText = "sample" var yamlPathTests = []struct { + summary string path1, path2 *setup.YAMLPath - areSame bool + result bool }{{ - path1: &setup.YAMLPath{ - Text: &sampleText, - Mutable: true, - Mode: 0644, - Arch: setup.YAMLArch{List: []string{"amd64", "arm64"}}, - }, - path2: &setup.YAMLPath{ - Text: &sampleText, - Mutable: true, - Mode: 0644, - Arch: setup.YAMLArch{List: []string{"amd64", "arm64"}}, - }, - areSame: true, + 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}, - areSame: true, + result: true, }, { + summary: "Symlink path", path1: &setup.YAMLPath{Symlink: "foo"}, path2: &setup.YAMLPath{Symlink: "foo"}, - areSame: true, + result: true, }, { + summary: "Generate path", path1: &setup.YAMLPath{Generate: setup.GenerateManifest}, path2: &setup.YAMLPath{Generate: setup.GenerateManifest}, - areSame: true, + result: true, +}, { + summary: "Copy path", + path1: &setup.YAMLPath{Copy: "foo"}, + path2: &setup.YAMLPath{Copy: "foo"}, + result: true, }, { - // "until" is not checked. + 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}, - areSame: true, + result: true, }, { - // Empty texts produce nil Text pointer. + summary: `Empty "text" produces nil pointer`, path1: &setup.YAMLPath{Text: nil}, path2: &setup.YAMLPath{Text: nil}, - areSame: true, + result: true, +}, { + summary: `Different "generate" values`, + 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) { for _, test := range yamlPathTests { - areSame := test.path1.SameContent(test.path2) - c.Assert(areSame, Equals, test.areSame) + c.Logf("Summary: %s", test.summary) + result := test.path1.SameContent(test.path2) + c.Assert(result, Equals, test.result) } }