diff --git a/internal/setup/export_test.go b/internal/setup/export_test.go new file mode 100644 index 00000000..35231e50 --- /dev/null +++ b/internal/setup/export_test.go @@ -0,0 +1,3 @@ +package setup + +type YAMLPath = yamlPath diff --git a/internal/setup/setup_test.go b/internal/setup/setup_test.go index 32e81428..a5d16613 100644 --- a/internal/setup/setup_test.go +++ b/internal/setup/setup_test.go @@ -2240,3 +2240,32 @@ func (s *S) TestParseSliceKey(c *C) { c.Assert(key, DeepEquals, test.expected) } } + +// This is an awkward test because right now the fact Generate is considered +// by SameContent is irrelevant to the implementation, because the code path +// happens to not touch it. More important than this test, there's an entry +// in setupTests that verifies that two packages with slices having +// {generate: manifest} in the same path are considered equal. +var yamlPathGenerateTests = []struct { + summary string + path1, path2 *setup.YAMLPath + result bool +}{{ + summary: `Same "generate" value`, + path1: &setup.YAMLPath{Generate: setup.GenerateManifest}, + path2: &setup.YAMLPath{Generate: setup.GenerateManifest}, + result: true, +}, { + summary: `Different "generate" value`, + path1: &setup.YAMLPath{Generate: setup.GenerateManifest}, + path2: &setup.YAMLPath{Generate: setup.GenerateNone}, + result: false, +}} + +func (s *S) TestYAMLPathGenerate(c *C) { + for _, test := range yamlPathGenerateTests { + c.Logf("Summary: %s", test.summary) + result := test.path1.SameContent(test.path2) + c.Assert(result, Equals, test.result) + } +} diff --git a/internal/setup/yaml.go b/internal/setup/yaml.go index 3f46f713..f2dbe127 100644 --- a/internal/setup/yaml.go +++ b/internal/setup/yaml.go @@ -84,7 +84,8 @@ func (yp *yamlPath) SameContent(other *yamlPath) bool { yp.Copy == other.Copy && yp.Text == other.Text && yp.Symlink == other.Symlink && - yp.Mutable == other.Mutable) + yp.Mutable == other.Mutable && + yp.Generate == other.Generate) } type yamlArch struct {