MCPcopy Create free account
hub / github.com/devnullvoid/pvetui / TestPrintError

Function TestPrintError

internal/cli/cli_helpers_test.go:91–106  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

89}
90
91func TestPrintError(t *testing.T) {
92 sentinel := errors.New("something went wrong")
93
94 got := captureStderr(t, func() {
95 _ = printError(sentinel)
96 })
97
98 var obj map[string]string
99 if err := json.Unmarshal([]byte(strings.TrimSpace(got)), &obj); err != nil {
100 t.Fatalf("stderr is not valid JSON: %v\noutput: %s", err, got)
101 }
102
103 if obj["error"] != sentinel.Error() {
104 t.Errorf("expected error %q, got %q", sentinel.Error(), obj["error"])
105 }
106}
107
108func TestPrintTable(t *testing.T) {
109 headers := []string{"NAME", "STATUS"}

Callers

nothing calls this directly

Calls 3

captureStderrFunction · 0.85
printErrorFunction · 0.85
ErrorMethod · 0.65

Tested by

no test coverage detected