g1t/apps/web/app/lib/go-get.test.ts

22 lines1,270 bytesCodeBlame

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Composer from the workspace's own repositories, and go get from g1t.sh1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { goImport } from "./go-get.ts";
5
6test("go get finds a repository's code from its address and any package in it", () => {
7 for (const path of ["/acme/lib", "/acme/lib/", "/acme/lib/pkg/sub", "/acme/lib.git"]) {
8 const page = goImport(new URL(`https://g1t.sh${path}?go-get=1`));
9 assert.ok(page, path);
10 assert.match(page, /<meta name="go-import" content="g1t\.sh\/acme\/lib git https:\/\/g1t\.sh\/acme\/lib\.git">/);
11 assert.match(page, /<meta name="go-source" content="g1t\.sh\/acme\/lib https:\/\/g1t\.sh\/acme\/lib /);
12 }
13});
14
15test("only go-get requests for a repository's address are answered", () => {
16 assert.equal(goImport(new URL("https://g1t.sh/acme/lib")), null, "no go-get");
17 assert.equal(goImport(new URL("https://g1t.sh/acme/lib?go-get=0")), null);
18 assert.equal(goImport(new URL("https://g1t.sh/acme?go-get=1")), null, "a workspace is not a module");
19 assert.equal(goImport(new URL("https://g1t.sh/acme/-/packages?go-get=1")), null, "workspace pages");
20 assert.equal(goImport(new URL("https://g1t.sh/Acme/lib?go-get=1")), null);
21 assert.equal(goImport(new URL("https://g1t.sh/acme/%22%3E?go-get=1")), null, "nothing is put in the page unchecked");
22});