Skip to content

Commit 10b04b8

Browse files
committed
fix: add test coverage for empty output format
Signed-off-by: Jonathan Ogilvie <jonathan.ogilvie@sumologic.com>
1 parent de98570 commit 10b04b8

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

cmd/diff/diffprocessor/processor_config_test.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@ func TestGetDiffOptions_PropagatesStdoutStderrFormat(t *testing.T) {
136136
}
137137
})
138138

139-
t.Run("NilWritersKeepDefaults", func(t *testing.T) {
139+
t.Run("ZeroValuesKeepDefaults", func(t *testing.T) {
140140
config := ProcessorConfig{
141141
Colorize: true,
142-
// Stdout and Stderr intentionally left nil
142+
// Stdout, Stderr, and OutputFormat intentionally left at zero value
143143
}
144144

145145
got := config.GetDiffOptions()
@@ -153,6 +153,13 @@ func TestGetDiffOptions_PropagatesStdoutStderrFormat(t *testing.T) {
153153
if got.Stderr != io.Writer(os.Stderr) {
154154
t.Errorf("Expected default os.Stderr when config.Stderr is nil, got: %v", got.Stderr)
155155
}
156+
157+
// When the config's OutputFormat is the zero value (""), DefaultDiffOptions()
158+
// default (OutputFormatDiff) should be preserved rather than overwritten with "".
159+
if got.Format != renderer.OutputFormatDiff {
160+
t.Errorf("Expected default Format %q when config.OutputFormat is empty, got %q",
161+
renderer.OutputFormatDiff, got.Format)
162+
}
156163
})
157164
}
158165

0 commit comments

Comments
 (0)