MCPcopy Create free account
hub / github.com/cli/cli / TestPrintPartialFailure

Function TestPrintPartialFailure

pkg/cmd/issue/artifact/shared/results_test.go:282–347  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

280}
281
282func TestPrintPartialFailure(t *testing.T) {
283 uploadErr := errors.New("could not upload latte-art.png: rate limited; wait and try again")
284
285 tests := []struct {
286 name string
287 tty bool
288 color bool
289 status string
290 result Result
291 message string
292 err error
293 wantStdout string
294 wantStderr string
295 }{
296 {
297 name: "in a terminal, the message and the reason go to stderr",
298 tty: true,
299 status: "created",
300 result: Result{Number: 6, Name: "signin-plan.md", Source: "signin-plan.md"},
301 message: "Created artifact 6 (signin-plan.md) on monalisa/monas-cafe#142",
302 err: uploadErr,
303 wantStderr: "! Created artifact 6 (signin-plan.md) on monalisa/monas-cafe#142, but could not upload latte-art.png: rate limited; wait and try again\n",
304 },
305 {
306 name: "colors in a terminal",
307 tty: true,
308 color: true,
309 status: "created",
310 result: Result{Number: 6, Name: "signin-plan.md", Source: "signin-plan.md"},
311 message: "Created artifact 6 (signin-plan.md) on monalisa/monas-cafe#142",
312 err: uploadErr,
313 wantStderr: "\x1b[0;33m!\x1b[0m Created artifact 6 (signin-plan.md) on monalisa/monas-cafe#142, but could not upload latte-art.png: rate limited; wait and try again\n",
314 },
315 {
316 name: "piped, the line keeps its status and has the reason",
317 status: "created",
318 result: Result{Number: 6, Name: "signin-plan.md", Source: "signin-plan.md"},
319 message: "Created artifact 6 (signin-plan.md) on monalisa/monas-cafe#142",
320 err: uploadErr,
321 wantStdout: "created\t6\tsignin-plan.md\tsignin-plan.md\tcould not upload latte-art.png: rate limited; wait and try again\n",
322 },
323 {
324 name: "a reason on several lines stays on one line",
325 status: "created",
326 result: Result{Number: 6, Name: "signin-plan.md", Source: "signin-plan.md"},
327 message: "Created artifact 6 (signin-plan.md) on monalisa/monas-cafe#142",
328 err: errors.New("could not upload latte-art.png: Validation Failed\nname is invalid"),
329 wantStdout: "created\t6\tsignin-plan.md\tsignin-plan.md\tcould not upload latte-art.png: Validation Failed name is invalid\n",
330 },
331 }
332
333 for _, tt := range tests {
334 t.Run(tt.name, func(t *testing.T) {
335 ios, _, stdout, stderr := iostreams.Test()
336 ios.SetStdinTTY(tt.tty)
337 ios.SetStdoutTTY(tt.tty)
338 ios.SetStderrTTY(tt.tty)
339 ios.SetColorEnabled(tt.color)

Callers

nothing calls this directly

Calls 9

TestFunction · 0.92
PrintPartialFailureFunction · 0.85
SetStdinTTYMethod · 0.80
SetStdoutTTYMethod · 0.80
SetStderrTTYMethod · 0.80
SetColorEnabledMethod · 0.80
EqualMethod · 0.80
RunMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected