Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

30 linesCodeBlameRaw
1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { confirmsSlug, deletionRefusal, whatGoes } from "./workspace-deletion.ts";
5
6const nothing = { repositories: 0, projects: 0, members: 0, billing: null, protected: false };
7
8test("what goes lists only what the workspace holds", () => {
9 assert.deepEqual(whatGoes(nothing, null), []);
10 assert.deepEqual(whatGoes({ ...nothing, repositories: 1, projects: 2, members: 1 }, 3), [
11 "1 repository, with its work items, pull requests and workflow runs",
12 "2 projects",
13 "3 live apps, taken offline",
14 "Access for 1 member; their own accounts stay",
15 ]);
16 assert.deepEqual(whatGoes({ ...nothing, repositories: 4 }, 0), ["4 repositories, with their work items, pull requests and workflow runs"]);
17});
18
19test("only billing or protection stands in the way", () => {
20 assert.equal(deletionRefusal("acme", null), null);
21 assert.equal(deletionRefusal("acme", { ...nothing, repositories: 9, projects: 2 }), null);
22 assert.equal(deletionRefusal("acme", { ...nothing, billing: "Pay first." }), "Pay first.");
23 assert.equal(deletionRefusal("flagon-io", { ...nothing, billing: "Pay first.", protected: true }), "flagon-io is protected and can never be deleted.");
24});
25
26test("the slug confirms in any case, and nothing else does", () => {
27 assert.ok(confirmsSlug("acme", " ACME "));
28 assert.ok(!confirmsSlug("acme", ""));
29 assert.ok(!confirmsSlug("acme", "acme-inc"));
30});