Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(setup): add missing "Generate" equivalency #173

Merged
merged 9 commits into from
Nov 25, 2024
3 changes: 3 additions & 0 deletions internal/setup/export_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package setup

type YAMLPath = yamlPath
29 changes: 29 additions & 0 deletions internal/setup/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}}
rebornplusplus marked this conversation as resolved.
Show resolved Hide resolved

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)
}
}
3 changes: 2 additions & 1 deletion internal/setup/yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading