flagon-io/g1t

public

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

g1t/services/runner/src/surroundings.test.ts

29 lines981 bytesCodeBlame
1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { readableSurroundings } from "./surroundings.ts";
5
6const projects = [
7 {
8 slug: "web",
9 name: "Web",
10 dependencies: {
11 dependsOn: [
12 { slug: "api", as: "API_URL" },
13 { slug: "billing", as: null },
14 ],
15 usedBy: [{ slug: "Admin", as: null }],
16 },
17 },
18];
19
20test("someone who reads every repository is told of every project around it", () => {
21 assert.deepEqual(readableSurroundings(projects, null), projects);
22});
23
24test("anyone else is told only of the projects they can read", () => {
25 const [web] = readableSurroundings(projects, new Set(["web", "api", "admin"]));
26 assert.deepEqual(web.dependencies.dependsOn.map((d) => d.slug), ["api"], "billing is not named");
27 assert.deepEqual(web.dependencies.usedBy.map((d) => d.slug), ["Admin"]);
28 assert.deepEqual(readableSurroundings(projects, new Set())[0].dependencies, { dependsOn: [], usedBy: [] });
29});