Skip to content

Commit e2ee603

Browse files
author
Rafid Bin Mostofa
authored
chore: add missing Generate equivalency (canonical#173)
Also consider Generate in yamlPath.SameContent. Implementation does not touch this right now. Co-authored-by: Alberto Carretero
1 parent a09dd15 commit e2ee603

3 files changed

Lines changed: 34 additions & 1 deletion

File tree

‎internal/setup/export_test.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package setup
2+
3+
type YAMLPath = yamlPath

‎internal/setup/setup_test.go‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2240,3 +2240,32 @@ func (s *S) TestParseSliceKey(c *C) {
22402240
c.Assert(key, DeepEquals, test.expected)
22412241
}
22422242
}
2243+
2244+
// This is an awkward test because right now the fact Generate is considered
2245+
// by SameContent is irrelevant to the implementation, because the code path
2246+
// happens to not touch it. More important than this test, there's an entry
2247+
// in setupTests that verifies that two packages with slices having
2248+
// {generate: manifest} in the same path are considered equal.
2249+
var yamlPathGenerateTests = []struct {
2250+
summary string
2251+
path1, path2 *setup.YAMLPath
2252+
result bool
2253+
}{{
2254+
summary: `Same "generate" value`,
2255+
path1: &setup.YAMLPath{Generate: setup.GenerateManifest},
2256+
path2: &setup.YAMLPath{Generate: setup.GenerateManifest},
2257+
result: true,
2258+
}, {
2259+
summary: `Different "generate" value`,
2260+
path1: &setup.YAMLPath{Generate: setup.GenerateManifest},
2261+
path2: &setup.YAMLPath{Generate: setup.GenerateNone},
2262+
result: false,
2263+
}}
2264+
2265+
func (s *S) TestYAMLPathGenerate(c *C) {
2266+
for _, test := range yamlPathGenerateTests {
2267+
c.Logf("Summary: %s", test.summary)
2268+
result := test.path1.SameContent(test.path2)
2269+
c.Assert(result, Equals, test.result)
2270+
}
2271+
}

‎internal/setup/yaml.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ func (yp *yamlPath) SameContent(other *yamlPath) bool {
8484
yp.Copy == other.Copy &&
8585
yp.Text == other.Text &&
8686
yp.Symlink == other.Symlink &&
87-
yp.Mutable == other.Mutable)
87+
yp.Mutable == other.Mutable &&
88+
yp.Generate == other.Generate)
8889
}
8990

9091
type yamlArch struct {

0 commit comments

Comments
 (0)