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
4 changes: 4 additions & 0 deletions internal/setup/export_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package setup

type YAMLPath = yamlPath
type YAMLArch = yamlArch
50 changes: 50 additions & 0 deletions internal/setup/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2240,3 +2240,53 @@ func (s *S) TestParseSliceKey(c *C) {
c.Assert(key, DeepEquals, test.expected)
}
}

var sampleText = "sample"

var yamlPathTests = []struct {
path1, path2 *setup.YAMLPath
areSame bool
rebornplusplus marked this conversation as resolved.
Show resolved Hide resolved
}{{
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,
}, {
path1: &setup.YAMLPath{Dir: true, Mode: 0755},
path2: &setup.YAMLPath{Dir: true, Mode: 0755},
areSame: true,
}, {
path1: &setup.YAMLPath{Symlink: "foo"},
path2: &setup.YAMLPath{Symlink: "foo"},
areSame: true,
}, {
path1: &setup.YAMLPath{Generate: setup.GenerateManifest},
path2: &setup.YAMLPath{Generate: setup.GenerateManifest},
areSame: true,
}, {
// "until" is not checked.
rebornplusplus marked this conversation as resolved.
Show resolved Hide resolved
path1: &setup.YAMLPath{Copy: "foo", Mutable: true, Until: setup.UntilMutate},
path2: &setup.YAMLPath{Copy: "foo", Mutable: true},
areSame: true,
}, {
// Empty texts produce nil Text pointer.
path1: &setup.YAMLPath{Text: nil},
path2: &setup.YAMLPath{Text: nil},
areSame: true,
}}
rebornplusplus marked this conversation as resolved.
Show resolved Hide resolved

func (s *S) TestYAMLPathSameContent(c *C) {
for _, test := range yamlPathTests {
areSame := test.path1.SameContent(test.path2)
c.Assert(areSame, Equals, test.areSame)
}
}
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