From e6661e3f3b57144989da374569700a1e9e8df192 Mon Sep 17 00:00:00 2001 From: itrytoohard Date: Mon, 1 Jun 2026 02:38:25 +0530 Subject: [PATCH] test(cli): pin ExitCode mapping (usage=2, runtime=1, nil=0) Closes the one nit from the regression audit: the exit-code wiring was correct and covered end-to-end by the smoke test, but not pinned by a unit test. Co-Authored-By: Claude Opus 4.8 (1M context) --- backend/internal/cli/exitcode_test.go | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 backend/internal/cli/exitcode_test.go diff --git a/backend/internal/cli/exitcode_test.go b/backend/internal/cli/exitcode_test.go new file mode 100644 index 000000000..bd8817c64 --- /dev/null +++ b/backend/internal/cli/exitcode_test.go @@ -0,0 +1,27 @@ +package cli + +import ( + "errors" + "fmt" + "testing" +) + +func TestExitCode(t *testing.T) { + cases := []struct { + name string + err error + want int + }{ + {"nil is success", nil, 0}, + {"runtime error is 1", errors.New("boom"), 1}, + {"usage error is 2", usageError{errors.New("bad flag")}, 2}, + {"wrapped usage error is still 2", fmt.Errorf("ctx: %w", usageError{errors.New("x")}), 2}, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + if got := ExitCode(tc.err); got != tc.want { + t.Errorf("ExitCode(%v) = %d, want %d", tc.err, got, tc.want) + } + }) + } +}