g1t/apps/web/app/lib/registry-paths.test.ts

121 lines4,220 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.

Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { servicePath } from "./registry-paths.ts";
5
6test("the container registry's paths go to the packages service", () => {
7 for (const path of [
8 "/v2",
9 "/v2/",
10 "/v2/token",
11 "/v2/acme/web/manifests/latest",
12 "/v2/acme/web/api/blobs/uploads/upl_1",
13 "/v2/acme/web/tags/list",
14 "/v2/acme/web/referrers/sha256:abc",
15 ]) {
16 assert.equal(servicePath(path), "packages", path);
17 }
18});
19
npm on g1t.sh: publish and install @<workspace>/<name> with the npm CLI and a g1t token20test("the npm registry's paths go to the packages service", () => {
21 for (const path of [
22 "/-/npm",
23 "/-/npm/",
24 "/-/npm/@acme%2fweb",
25 "/-/npm/@acme/web/-/web-1.0.0.tgz",
26 "/-/npm/-/package/@acme%2fweb/dist-tags/next",
27 "/-/npm/-/whoami",
28 // A package named like a git endpoint is still npm's.
29 "/-/npm/@acme/info/refs",
30 ]) {
31 assert.equal(servicePath(path), "packages", path);
32 }
33 for (const path of ["/-/npmx", "/acme/-/npm", "/acme/-/packages"]) {
34 assert.equal(servicePath(path), null, path);
35 }
36});
37
Composer from the workspace's own repositories, and go get from g1t.sh38test("the Composer registries go to the packages service", () => {
39 for (const path of [
40 "/-/composer/acme/packages.json",
41 "/-/composer/acme/p2/acme/lib.json",
42 "/-/composer/acme/p2/acme/lib~dev.json",
43 `/-/composer/acme/dist/acme/lib/${"a".repeat(40)}.zip`,
44 ]) {
45 assert.equal(servicePath(path), "packages", path);
46 }
47 assert.equal(servicePath("/-/composer"), null);
48});
49
Cargo on g1t.sh: a sparse registry per workspace, cargo publish/add/yank/search with a g1t token; npm rows show their version50test("the Cargo registries go to the packages service", () => {
51 for (const path of [
52 "/-/cargo/acme/index/config.json",
53 "/-/cargo/acme/index/se/rd/serde",
54 "/-/cargo/acme/index/3/a/abc",
55 "/-/cargo/acme/api/v1/crates/new",
56 "/-/cargo/acme/api/v1/crates/serde/1.0.0/download",
57 "/-/cargo/acme/api/v1/crates/serde/1.0.0/yank",
58 // A crate named like a git endpoint is still Cargo's.
59 "/-/cargo/acme/index/in/fo/info/refs",
60 ]) {
61 assert.equal(servicePath(path), "packages", path);
62 }
63 assert.equal(servicePath("/-/cargo"), null);
64 assert.equal(servicePath("/acme/-/cargo/x"), null);
65});
66
Merge branch 'worktree-agent-a6a121745e81f639f'67test("the Maven repositories go to the packages service", () => {
68 for (const path of [
69 "/-/maven/acme/com/acme/web/maven-metadata.xml",
70 "/-/maven/acme/com/acme/web/maven-metadata.xml.sha1",
71 "/-/maven/acme/com/acme/web/1.0.0/web-1.0.0.jar",
72 "/-/maven/acme/com/acme/web/1.0-SNAPSHOT/web-1.0-20261006.120000-1.pom",
73 // An artifact named like a git endpoint is still Maven's.
74 "/-/maven/acme/com/acme/info/refs",
75 ]) {
76 assert.equal(servicePath(path), "packages", path);
77 }
78 assert.equal(servicePath("/-/maven"), null);
79 assert.equal(servicePath("/acme/-/maven/x"), null);
80});
81
82test("the NuGet feeds go to the packages service", () => {
83 for (const path of [
84 "/-/nuget/acme/v3/index.json",
85 "/-/nuget/acme/v3/flatcontainer/acme.web/index.json",
86 "/-/nuget/acme/v3/flatcontainer/acme.web/1.0.0/acme.web.1.0.0.nupkg",
87 "/-/nuget/acme/v3/registration/acme.web/index.json",
88 "/-/nuget/acme/v3/query",
89 "/-/nuget/acme/api/v2/package",
90 "/-/nuget/acme/api/v2/package/Acme.Web/1.0.0",
91 ]) {
92 assert.equal(servicePath(path), "packages", path);
93 }
94 assert.equal(servicePath("/-/nuget"), null);
95 assert.equal(servicePath("/acme/-/nuget/x"), null);
96});
97
98test("the RubyGems registries go to the packages service", () => {
99 for (const path of [
100 "/-/rubygems/acme/versions",
101 "/-/rubygems/acme/info/hello",
102 "/-/rubygems/acme/names",
103 "/-/rubygems/acme/gems/hello-0.1.0.gem",
104 "/-/rubygems/acme/api/v1/gems",
105 "/-/rubygems/acme/api/v1/gems/yank",
106 ]) {
107 assert.equal(servicePath(path), "packages", path);
108 }
109 assert.equal(servicePath("/-/rubygems"), null);
110 assert.equal(servicePath("/acme/-/rubygems/x"), null);
111});
112
Packages, with a container registry on g1t.sh; workspaces deleted whole and kept 30 days; Members for every member113test("git goes to repos, and everything else is the site's", () => {
114 assert.equal(servicePath("/acme/web.git/info/refs"), "git");
115 assert.equal(servicePath("/acme/web/git-receive-pack"), "git");
116 // A registry image named like a git endpoint is still the registry's.
117 assert.equal(servicePath("/v2/acme/info/refs"), "packages");
118 for (const path of ["/", "/acme", "/acme/web", "/v2x", "/acme/v2", "/acme/-/packages"]) {
119 assert.equal(servicePath(path), null, path);
120 }
121});

This file's history is long; its oldest lines are credited to the oldest commit read.