TestHandleRootError_PartialWritePreservesExitCode pins that when the stderr write fails mid-envelope, handleRootError still returns the typed exit code (ExitAuth=3 for AuthenticationError), not fall through to the plain "Error:" path with exit 1. ExitCodeOf is computed from the typed err BEFORE the
(t *testing.T)
| 442 | // err BEFORE the envelope write so the exit code is preserved even when |
| 443 | // the consumer's stderr pipe dies. |
| 444 | func TestHandleRootError_PartialWritePreservesExitCode(t *testing.T) { |
| 445 | t.Setenv("LARKSUITE_CLI_CONFIG_DIR", t.TempDir()) |
| 446 | |
| 447 | f, _, _, _ := cmdutil.TestFactory(t, nil) |
| 448 | w := &failingWriter{limit: 20} |
| 449 | f.IOStreams.ErrOut = w |
| 450 | |
| 451 | err := errs.NewAuthenticationError(errs.SubtypeTokenExpired, "token expired") |
| 452 | exit := handleRootError(f, err) |
| 453 | if exit != int(output.ExitAuth) { |
| 454 | t.Errorf("exit = %d, want %d (typed exit code preserved despite write failure)", exit, int(output.ExitAuth)) |
| 455 | } |
| 456 | } |
| 457 | |
| 458 | // TestHandleRootError_BareErrorExitCodeNoStderr pins the silent-exit |
| 459 | // contract: a *output.BareError is honored for its exit code while stderr stays |
nothing calls this directly
no test coverage detected