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.

56 linesCodeBlameRaw
1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { HOSTED_ADDRESSES, addressesFor, addressesFrom, cloneUrl, usercontentFrom } from "./addresses.ts";
5import { MCP_URL } from "./agent-setup.ts";
6import { OG, SITE } from "./meta.ts";
7
8test("with no settings, the addresses are g1t.sh's", () => {
9 assert.deepEqual(addressesFor({}), HOSTED_ADDRESSES);
10 assert.deepEqual(addressesFor({ SITE_URL: "", API_URL: "", MCP_URL: "" }), HOSTED_ADDRESSES);
11});
12
13test("settings replace the addresses, without trailing slashes", () => {
14 assert.deepEqual(
15 addressesFor({
16 SITE_URL: "http://localhost:8787/",
17 API_URL: "http://localhost:8788",
18 MCP_URL: "http://localhost:8790/mcp/",
19 OG_URL: "",
20 }),
21 {
22 site: "http://localhost:8787",
23 api: "http://localhost:8788",
24 mcp: "http://localhost:8790/mcp",
25 og: null,
26 usercontent: "http://localhost:8787/-/usercontent",
27 },
28 );
29});
30
31test("files people supply are served from an origin of their own", () => {
32 assert.equal(addressesFor({}).usercontent, "https://g1tusercontent.com");
33 assert.equal(addressesFor({ SITE_URL: "https://git.example.com", USERCONTENT_URL: "https://files.example.net/" }).usercontent, "https://files.example.net");
34 assert.equal(
35 addressesFor({ SITE_URL: "https://git.example.com", USERCONTENT_URL: "https://git.example.com" }).usercontent,
36 "https://git.example.com/-/usercontent",
37 );
38 assert.equal(usercontentFrom(undefined), "");
39 assert.equal(usercontentFrom({ addresses: HOSTED_ADDRESSES }), "https://g1tusercontent.com");
40});
41
42test("pages without root data use g1t.sh's addresses", () => {
43 assert.deepEqual(addressesFrom(undefined), HOSTED_ADDRESSES);
44 const own = { site: "http://localhost:8787", api: "a", mcp: "m", og: null };
45 assert.deepEqual(addressesFrom({ addresses: own }), own);
46});
47
48test("the defaults kept in meta and agent setup are g1t.sh's", () => {
49 assert.equal(SITE, HOSTED_ADDRESSES.site);
50 assert.equal(OG, HOSTED_ADDRESSES.og);
51 assert.equal(MCP_URL, HOSTED_ADDRESSES.mcp);
52});
53
54test("a clone address is under the site", () => {
55 assert.equal(cloneUrl(HOSTED_ADDRESSES, "acme/web"), "https://g1t.sh/acme/web.git");
56});