(t *testing.T)
| 349 | } |
| 350 | |
| 351 | func TestRenderCommandErrorIncludesCodedDetails(t *testing.T) { |
| 352 | var stdout bytes.Buffer |
| 353 | var stderr bytes.Buffer |
| 354 | cmd := &cobra.Command{Use: "mkdir"} |
| 355 | cmd.SetOut(&stdout) |
| 356 | cmd.SetErr(&stderr) |
| 357 | cmd.Flags().String(outputFlag, "json", "") |
| 358 | |
| 359 | renderCommandError(cmd, pathConflictErrorWithPath("/file", "path exists and is not a folder: %s", "/file")) |
| 360 | |
| 361 | if got := stderr.String(); got != "" { |
| 362 | t.Fatalf("stderr = %q, want empty", got) |
| 363 | } |
| 364 | got := decodeJSONErrorResponse(t, stdout.String()) |
| 365 | if got.Error.Code != jsonErrorCodePathConflict { |
| 366 | t.Fatalf("code = %q, want %q", got.Error.Code, jsonErrorCodePathConflict) |
| 367 | } |
| 368 | if got.Error.Details["path"] != "/file" { |
| 369 | t.Fatalf("details = %+v, want path", got.Error.Details) |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | func TestRenderCommandErrorIncludesArgumentAndFlagDetails(t *testing.T) { |
| 374 | var stdout bytes.Buffer |
nothing calls this directly
no test coverage detected