MCPcopy
hub / github.com/opentofu/opentofu / TestOutputJSON_empty

Function TestOutputJSON_empty

internal/command/views/output_test.go:219–232  ·  view source on GitHub ↗

JSON output format supports empty outputs by rendering an empty object without diagnostics.

(t *testing.T)

Source from the content-addressed store, hash-verified

217// JSON output format supports empty outputs by rendering an empty object
218// without diagnostics.
219func TestOutputJSON_empty(t *testing.T) {
220 streams, done := terminal.StreamsForTesting(t)
221 v := NewOutput(arguments.ViewOptions{ViewType: arguments.ViewJSON}, NewView(streams))
222
223 diags := v.Output("", map[string]*states.OutputValue{})
224
225 if diags.HasErrors() {
226 t.Fatalf("unexpected diagnostics: %s", diags)
227 }
228
229 if got, want := done(t).Stdout(), "{}\n"; got != want {
230 t.Errorf("wrong result\ngot: %q\nwant: %q", got, want)
231 }
232}
233
234// Human and raw formats render a warning if there are no outputs.
235func TestOutput_emptyWarning(t *testing.T) {

Callers

nothing calls this directly

Calls 6

OutputMethod · 0.95
StreamsForTestingFunction · 0.92
NewOutputFunction · 0.85
NewViewFunction · 0.85
HasErrorsMethod · 0.80
StdoutMethod · 0.80

Tested by

no test coverage detected