Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions test/unit/connect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ describe("prepareConnection", () => {
})

it("shows a refusal with its action, then closes the remote", async () => {
const { deps, seen } = setup({ FAKE_SPIN_ERROR: "no_key_held" })
const { deps, seen } = setup({ FAKE_SPIN_ERROR: "key_not_enrolled" })
expect(await prepareConnection(deps, "ssh-remote", "ssh-remote+spin.my-ws")).toBe(false)
expect(seen.errors).toHaveLength(1)
expect((seen.errors[0] as CliError).code).toBe("no_key_held")
expect((seen.errors[0] as CliError).code).toBe("key_not_enrolled")
expect(seen.closed).toBe(1)
})

Expand Down
16 changes: 10 additions & 6 deletions test/unit/proxy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,19 @@ describe("fileProxyStatus", () => {
})

describe("proxyFailure", () => {
it("is the CLI's envelope for a code the contract knows", () => {
const error = { code: "no_capacity", action: "retry", message: "full" }
expect(proxyFailure(status("failed", { error }))).toEqual({ envelope: { error } })
it.each([
["a refusal", "refused", KEY_NOT_ENROLLED],
["a failure", "failed", { code: "no_capacity", action: "retry", message: "full" }],
] as const)("is the CLI's envelope, with its action, for %s", (_what, phase, error) => {
expect(proxyFailure(status(phase, { error }))).toEqual({ envelope: { error } })
})

// A release newer than the contract can write a code it does not know yet.
it("is the message and its page for a code the contract does not know", () => {
expect(proxyFailure(status("refused", { error: KEY_NOT_ENROLLED }))).toEqual({
message: `Spinbox could not connect to ${HOST}: ${KEY_NOT_ENROLLED.message}`,
url: KEY_NOT_ENROLLED.url,
const error = { ...KEY_NOT_ENROLLED, code: "key_revoked" }
expect(proxyFailure(status("refused", { error }))).toEqual({
message: `Spinbox could not connect to ${HOST}: ${error.message}`,
url: error.url,
})
})

Expand Down
Loading