Skip to content

Commit

Permalink
chore: add missing Generate equivalency (#173)
Browse files Browse the repository at this point in the history
Also consider Generate in yamlPath.SameContent. Implementation does not touch this right now.

Co-authored-by: Alberto Carretero
  • Loading branch information
rebornplusplus authored Nov 25, 2024
1 parent a09dd15 commit e2ee603
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
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,
}}

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

0 comments on commit e2ee603

Please sign in to comment.