Move configuration reports to shared rendering
This commit is contained in:
@@ -83,20 +83,11 @@ func TestComparisonHelpLimitsFlagsAndDefaultsFormatToYAML(t *testing.T) {
|
||||
if !strings.Contains(diffHelp, "--against-config") || !strings.Contains(diffHelp, "--against-overlay") {
|
||||
t.Fatalf("diff help omits right-side selection flags:\n%s", diffHelp)
|
||||
}
|
||||
if !strings.Contains(diffHelp, "default: yaml") {
|
||||
t.Fatalf("diff help does not show the YAML default:\n%s", diffHelp)
|
||||
}
|
||||
for _, operation := range []string{"validate", "show", "sources", "explain"} {
|
||||
operationHelp := help("config", operation, "--help")
|
||||
if strings.Contains(operationHelp, "--against-config") || strings.Contains(operationHelp, "--against-overlay") {
|
||||
t.Errorf("%s exposes comparison-only flags:\n%s", operation, operationHelp)
|
||||
}
|
||||
if operation == "show" && !strings.Contains(operationHelp, "default: yaml") {
|
||||
t.Errorf("show format default changed:\n%s", operationHelp)
|
||||
}
|
||||
if operation != "show" && !strings.Contains(operationHelp, "default: text") {
|
||||
t.Errorf("%s format default changed:\n%s", operation, operationHelp)
|
||||
}
|
||||
if operation != "explain" && strings.Contains(operationHelp, "--path") {
|
||||
t.Errorf("%s exposes the explain-only path flag:\n%s", operation, operationHelp)
|
||||
}
|
||||
@@ -107,7 +98,7 @@ func TestComparisonHelpLimitsFlagsAndDefaultsFormatToYAML(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestComparisonPreparationAcceptsOnlyYAML(t *testing.T) {
|
||||
func TestComparisonPreparation(t *testing.T) {
|
||||
inputCalls, stateCalls := 0, 0
|
||||
prepared := captureSuite(Suite[struct{}, struct{}]{
|
||||
NewInput: func() struct{} { inputCalls++; return struct{}{} },
|
||||
@@ -123,12 +114,11 @@ func TestComparisonPreparationAcceptsOnlyYAML(t *testing.T) {
|
||||
input := &configCommandInput[struct{}, struct{}]{
|
||||
selection: Selection{Config: commandkit.Supplied[string]{Value: "before.yml", Set: true}},
|
||||
against: Selection{Overlay: commandkit.Supplied[string]{Value: "candidate", Set: true}},
|
||||
format: commandkit.Supplied[string]{Value: "yaml", Set: true},
|
||||
}
|
||||
if err := prepareConfigOperation(prepared, Diff, input); err != nil {
|
||||
t.Fatalf("explicit YAML format rejected: %v", err)
|
||||
}
|
||||
if input.plan == nil || input.plan.format != "yaml" {
|
||||
if input.plan == nil {
|
||||
t.Fatalf("comparison plan = %#v", input.plan)
|
||||
}
|
||||
if input.plan.scopeName != "app" {
|
||||
@@ -141,12 +131,6 @@ func TestComparisonPreparationAcceptsOnlyYAML(t *testing.T) {
|
||||
t.Fatalf("resolved right selection = %#v, want %#v", input.against, want)
|
||||
}
|
||||
|
||||
for _, format := range []string{"text", "json"} {
|
||||
input := &configCommandInput[struct{}, struct{}]{format: commandkit.Supplied[string]{Value: format}}
|
||||
if err := prepareConfigOperation(prepared, Diff, input); err == nil {
|
||||
t.Errorf("comparison format %q was accepted", format)
|
||||
}
|
||||
}
|
||||
if inputCalls != 2 || stateCalls != 0 {
|
||||
t.Fatalf("comparison preparation calls input/state: %d/%d", inputCalls, stateCalls)
|
||||
}
|
||||
@@ -170,8 +154,7 @@ func TestComparisonAvailabilityPreflightPrecedesFactories(t *testing.T) {
|
||||
})
|
||||
for _, scope := range []string{"missing", "all", "plain"} {
|
||||
input := &configCommandInput[struct{}, struct{}]{
|
||||
scope: commandkit.Supplied[string]{Value: scope, Set: true},
|
||||
format: commandkit.Supplied[string]{Value: "yaml"},
|
||||
scope: commandkit.Supplied[string]{Value: scope, Set: true},
|
||||
}
|
||||
if err := prepareConfigOperation(prepared, Diff, input); err == nil {
|
||||
t.Errorf("comparison scope %q was accepted", scope)
|
||||
|
||||
Reference in New Issue
Block a user