Skip to content
Myr

exit-code.test.ts

This file

Path

packages/protocol/test/exit-code.test.ts

100 lines · 2.5 KiB · TypeScript

Last changed by

Merge project/drop-proposals into mainoscabrielbefore adoptionb4ed08b

History of this file

Take it

Merge cli/exit-codes into mainoscabrielbefore adoptionc19a862

lines 1–28why, one step back
1import { describe, expect, it } from "@effect/vitest";
23import {4 ExitCode,5 exitCodeFor,6 exitCodeOf,7 exitCodeOfTag,8} from "../src/exit-code.ts";9import {10 AskFull,11 NotVouched,12 OutOfScope,13 StaleBase,14 UnknownAsk,15} from "../src/refusal.ts";16import type { Refusal } from "../src/refusal.ts";17import { ask, base, examples, main, path } from "./examples.ts";1819const pinned = {20 AskBlocked: 75,21 AskFull: 75,22 AttemptsExhausted: 75,23 CapReached: 75,24 ChecksFailed: 65,25 ClaimLapsed: 75,26 DecisionClosed: 66,27 Denounced: 77,28 DirectPush: 77,

Merge project/discussions into mainoscabrielbefore adoption29b0353

line 29why, one step back
29 DiscussionClosed: 66,

Merge cli/exit-codes into mainoscabrielbefore adoptionc19a862

lines 30–40why, one step back
30 Flake: 75,
31 HeldBackFailed: 65,32 ImportFailed: 75,33 IncompleteBrief: 65,34 LayerContentInPublicTree: 65,35 NoAsk: 66,36 NotClaimed: 75,37 NotDecider: 77,38 NotRedFirst: 65,39 NotSensitive: 65,40 NotVouched: 77,

Merge build/1400-w14-foundation into mainoscabrielbefore adoption47dd2f8

line 41why, one step back
41 NotYourNamespace: 77,

Merge cli/exit-codes into mainoscabrielbefore adoptionc19a862

lines 42–54why, one step back
42 OutOfScope: 65,
43 PostureChange: 65,44 PrivatePathInPublicTree: 65,45 ProjectExists: 65,46 ReachedInternals: 65,47 RepoBusy: 75,48 SecretInOutput: 65,49 StaleBase: 75,50 StaleLayer: 75,51 TouchedJudge: 65,52 UnknownAsk: 66,53 UnknownCommit: 66,54 UnknownDecision: 66,

Merge project/discussions into mainoscabrielbefore adoption29b0353

line 55why, one step back
55 UnknownDiscussion: 66,

Merge cli/exit-codes into mainoscabrielbefore adoptionc19a862

lines 56–100why, one step back
56 UnknownEnvItem: 66,
57 UnknownPath: 66,58 UnknownProject: 66,59 UnknownRevision: 66,60 UnstatedRequirement: 65,61 ValueTooShort: 65,62 VerifierBlocked: 75,63 WeakCheck: 65,64 Weakened: 65,65} as const satisfies Record<Refusal["_tag"], number>;6667describe("a refusal's exit code", () => {68 it.each(examples)("$_tag ends the CLI with its pinned code", (refusal) => {69 expect(exitCodeOf(refusal)).toBe(pinned[refusal._tag]);70 });7172 it.each(examples)("$_tag has the same code by its tag alone", (refusal) => {73 expect(exitCodeOfTag(refusal._tag)).toBe(exitCodeOf(refusal));74 });7576 it.each(examples)("$_tag is 75 exactly when it is retryable", (refusal) => {77 expect(exitCodeOf(refusal) === ExitCode.tempFail).toBe(refusal.retryable);78 });79});8081describe("refusals met together", () => {82 const stale = new StaleBase({ base, conflicts: [path], main });83 const outOfScope = new OutOfScope({ paths: [path] });8485 it("end with 75 only when every one is retryable", () => {86 expect([87 exitCodeFor([stale, new AskFull({ ask })]),88 exitCodeFor([stale, outOfScope]),89 ]).toStrictEqual([ExitCode.tempFail, ExitCode.dataErr]);90 });9192 it("end with who is asking first, then what was named, then what was sent", () => {93 const unknown = new UnknownAsk({ ask });9495 expect([96 exitCodeFor([outOfScope, unknown, new NotVouched({})]),97 exitCodeFor([outOfScope, unknown]),98 ]).toStrictEqual([ExitCode.noPerm, ExitCode.noInput]);99 });100});