Separate comparison side selectors
This commit is contained in:
@@ -10,57 +10,6 @@ import (
|
||||
configkit "go.maximumdirect.net/configkit"
|
||||
)
|
||||
|
||||
func TestComparisonSelectionInheritsFieldsIndependently(t *testing.T) {
|
||||
leftConfig := commandkit.Supplied[string]{Value: "before.yml", Set: true}
|
||||
leftOverlay := commandkit.Supplied[string]{Value: "base", Set: true}
|
||||
tests := []struct {
|
||||
name string
|
||||
left Selection
|
||||
right Selection
|
||||
want Selection
|
||||
}{
|
||||
{
|
||||
name: "omitted fields stay omitted",
|
||||
},
|
||||
{
|
||||
name: "both fields inherit supplied state",
|
||||
left: Selection{Config: leftConfig, Overlay: leftOverlay},
|
||||
want: Selection{Config: leftConfig, Overlay: leftOverlay},
|
||||
},
|
||||
{
|
||||
name: "explicit empty config overrides while overlay inherits",
|
||||
left: Selection{Config: leftConfig, Overlay: leftOverlay},
|
||||
right: Selection{Config: commandkit.Supplied[string]{Set: true}},
|
||||
want: Selection{Config: commandkit.Supplied[string]{Set: true}, Overlay: leftOverlay},
|
||||
},
|
||||
{
|
||||
name: "explicit overlay overrides while config inherits",
|
||||
left: Selection{Config: leftConfig, Overlay: leftOverlay},
|
||||
right: Selection{Overlay: commandkit.Supplied[string]{Value: "candidate", Set: true}},
|
||||
want: Selection{Config: leftConfig, Overlay: commandkit.Supplied[string]{Value: "candidate", Set: true}},
|
||||
},
|
||||
{
|
||||
name: "explicit empty overlay remains supplied",
|
||||
left: Selection{Config: leftConfig, Overlay: leftOverlay},
|
||||
right: Selection{Overlay: commandkit.Supplied[string]{Set: true}},
|
||||
want: Selection{Config: leftConfig, Overlay: commandkit.Supplied[string]{Set: true}},
|
||||
},
|
||||
{
|
||||
name: "both explicit right fields replace left",
|
||||
left: Selection{Config: leftConfig, Overlay: leftOverlay},
|
||||
right: Selection{Config: commandkit.Supplied[string]{Value: "after.yml", Set: true}, Overlay: commandkit.Supplied[string]{Value: "new", Set: true}},
|
||||
want: Selection{Config: commandkit.Supplied[string]{Value: "after.yml", Set: true}, Overlay: commandkit.Supplied[string]{Value: "new", Set: true}},
|
||||
},
|
||||
}
|
||||
for _, test := range tests {
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
if got := inheritComparisonSelection(test.left, test.right); got != test.want {
|
||||
t.Fatalf("inherited selection = %#v, want %#v", got, test.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestComparisonHelpLimitsFlagsAndDefaultsFormatToYAML(t *testing.T) {
|
||||
scope := Scope[struct{}, struct{}]{
|
||||
Name: "app", Operations: []Operation{Diff, Show, Explain, Validate, Sources},
|
||||
@@ -125,7 +74,6 @@ func TestComparisonPreparation(t *testing.T) {
|
||||
t.Fatalf("comparison default scope = %q, want app", input.plan.scopeName)
|
||||
}
|
||||
if want := (Selection{
|
||||
Config: commandkit.Supplied[string]{Value: "before.yml", Set: true},
|
||||
Overlay: commandkit.Supplied[string]{Value: "candidate", Set: true},
|
||||
}); input.against != want {
|
||||
t.Fatalf("resolved right selection = %#v, want %#v", input.against, want)
|
||||
|
||||
Reference in New Issue
Block a user