MCPcopy
hub / github.com/larksuite/cli / TestHandleRootError_BareErrorExitCodeNoStderr

Function TestHandleRootError_BareErrorExitCodeNoStderr

cmd/root_test.go:462–476  ·  view source on GitHub ↗

TestHandleRootError_BareErrorExitCodeNoStderr pins the silent-exit contract: a *output.BareError is honored for its exit code while stderr stays empty (stdout already carries the result, so the dispatcher must not layer a second envelope on top).

(t *testing.T)

Source from the content-addressed store, hash-verified

460// empty (stdout already carries the result, so the dispatcher must not layer a
461// second envelope on top).
462func TestHandleRootError_BareErrorExitCodeNoStderr(t *testing.T) {
463 t.Setenv("LARKSUITE_CLI_CONFIG_DIR", t.TempDir())
464
465 f, _, _, _ := cmdutil.TestFactory(t, nil)
466 errOut := &bytes.Buffer{}
467 f.IOStreams.ErrOut = errOut
468
469 exit := handleRootError(f, output.ErrBare(output.ExitAuth))
470 if exit != int(output.ExitAuth) {
471 t.Errorf("exit = %d, want %d (BareError code propagated)", exit, int(output.ExitAuth))
472 }
473 if errOut.Len() != 0 {
474 t.Errorf("stderr must stay empty for a bare predicate signal, got:\n%s", errOut.String())
475 }
476}
477
478// TestHandleRootError_TypedAuthErrorWithLegacyCausePreserved pins that a typed
479// *errs.AuthenticationError carrying a legacy *NeedAuthorizationError in its

Callers

nothing calls this directly

Calls 4

TestFactoryFunction · 0.92
ErrBareFunction · 0.92
handleRootErrorFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected