Skip to content

Commit 1dc8c51

Browse files
committed
test: use an unresolvable fixture owner instead of the real "acme" account
Fixes #539
1 parent dd99add commit 1dc8c51

17 files changed

Lines changed: 224 additions & 104 deletions

‎packages/cli/src/auth/org.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ type WhoamiData = WhoamiResult;
2020
* - `installationId` is intentionally dropped — the CLI never uses it and it
2121
* should not be sent to us.
2222
*
23-
* `url` is the canonical OWNER url (e.g. `https://github.com/acme`) matched
24-
* against the repo's remotes.
23+
* `url` is the canonical OWNER url (e.g.
24+
* `https://github.com/__taskless_test__`) matched against the repo's remotes.
2525
*/
2626
export type WhoamiOrg = Omit<
2727
WhoamiData["orgs"][number],

‎packages/cli/src/util/git-remote.ts‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -344,13 +344,14 @@ export function canonicalRepositoryPath(remote: string): string | null {
344344
// self-hosted GitLab serves repositories under nested subgroups, and
345345
// collapsing them looked attractive because a renamed group would then not
346346
// change the identity. It trades the wrong way: dropping the middle makes
347-
// `acme/team1/api` and `acme/team2/api` — two unrelated repositories that
348-
// happen to share an owner and a leaf name — one identity, silently
349-
// undercounting in exactly the nested-group case this parser exists to
350-
// serve. A rename is the milder failure and the visible one: it starts a
351-
// new id on a date someone can find, where a collision is never visible at
352-
// all. It is also the same class of event as a GitHub transfer, which
353-
// already changes the identity here and is accepted.
347+
// `__taskless_test__/team1/api` and `__taskless_test__/team2/api` — two
348+
// unrelated repositories that happen to share an owner and a leaf name —
349+
// one identity, silently undercounting in exactly the nested-group case
350+
// this parser exists to serve. A rename is the milder failure and the
351+
// visible one: it starts a new id on a date someone can find, where a
352+
// collision is never visible at all. It is also the same class of event as
353+
// a GitHub transfer, which already changes the identity here and is
354+
// accepted.
354355
const cleaned = segments.map((segment) => segment.toLowerCase());
355356
cleaned[cleaned.length - 1] = cleaned.at(-1)!.replace(/\.git$/i, "");
356357
if (cleaned.some((segment) => segment.length === 0)) return null;

‎packages/cli/test/adoption-dimensions.test.ts‎

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ describe("workspaceId identifies the workspace, not the directory", () => {
7373

7474
describe("repositoryId is host-agnostic", () => {
7575
it("resolves a non-GitHub remote", async () => {
76-
const root = makeRepository("git@gitlab.com:acme/widgets.git");
76+
const root = makeRepository("git@gitlab.com:__taskless_test__/widgets.git");
7777

7878
// The case a GitHub-shaped implementation silently gets wrong: a GitLab
7979
// repository is a codebase like any other and must be counted.
@@ -116,18 +116,20 @@ describe("canonicalRepositoryPath", () => {
116116
});
117117

118118
it("keeps non-GitHub hosts distinct", () => {
119-
expect(canonicalRepositoryPath("git@gitlab.com:acme/widgets.git")).toBe(
120-
"gitlab.com/acme/widgets"
121-
);
122-
expect(canonicalRepositoryPath("https://git.internal/acme/widgets")).toBe(
123-
"git.internal/acme/widgets"
124-
);
119+
expect(
120+
canonicalRepositoryPath("git@gitlab.com:__taskless_test__/widgets.git")
121+
).toBe("gitlab.com/__taskless_test__/widgets");
122+
expect(
123+
canonicalRepositoryPath("https://git.internal/__taskless_test__/widgets")
124+
).toBe("git.internal/__taskless_test__/widgets");
125125
});
126126

127127
it("keeps the whole nested group path", () => {
128128
expect(
129-
canonicalRepositoryPath("git@gitlab.com:acme/team/sub/widgets.git")
130-
).toBe("gitlab.com/acme/team/sub/widgets");
129+
canonicalRepositoryPath(
130+
"git@gitlab.com:__taskless_test__/team/sub/widgets.git"
131+
)
132+
).toBe("gitlab.com/__taskless_test__/team/sub/widgets");
131133
});
132134

133135
it("does not collapse two repositories that share an owner and a leaf name", () => {
@@ -136,8 +138,10 @@ describe("canonicalRepositoryPath", () => {
136138
// undercounting distinct codebases in exactly the nested-group case this
137139
// parser exists to serve.
138140
expect(
139-
canonicalRepositoryPath("git@gitlab.com:acme/team1/api.git")
140-
).not.toBe(canonicalRepositoryPath("git@gitlab.com:acme/team2/api.git"));
141+
canonicalRepositoryPath("git@gitlab.com:__taskless_test__/team1/api.git")
142+
).not.toBe(
143+
canonicalRepositoryPath("git@gitlab.com:__taskless_test__/team2/api.git")
144+
);
141145
});
142146

143147
it("returns null when there is no owner/repo pair", () => {

‎packages/cli/test/anonymous-flag.test.ts‎

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,12 @@ describe("local authoring needs no GitHub remote", () => {
229229
await execFileAsync("git", ["init"], { cwd });
230230
await execFileAsync(
231231
"git",
232-
["remote", "add", "origin", "https://gitlab.com/acme/widgets.git"],
232+
[
233+
"remote",
234+
"add",
235+
"origin",
236+
"https://gitlab.com/__taskless_test__/widgets.git",
237+
],
233238
{ cwd }
234239
);
235240
},
@@ -319,12 +324,19 @@ describe("info reports the repository context", () => {
319324
await execFileAsync("git", ["init"], { cwd });
320325
await execFileAsync(
321326
"git",
322-
["remote", "add", "origin", "git@github.com:acme/widgets.git"],
327+
[
328+
"remote",
329+
"add",
330+
"origin",
331+
"git@github.com:__taskless_test__/widgets.git",
332+
],
323333
{ cwd }
324334
);
325335
const info = await readInfo();
326-
expect(info.repositoryUrl).toBe("https://github.com/acme/widgets");
327-
expect(info.ghOwner).toBe("acme");
336+
expect(info.repositoryUrl).toBe(
337+
"https://github.com/__taskless_test__/widgets"
338+
);
339+
expect(info.ghOwner).toBe("__taskless_test__");
328340
});
329341

330342
it("reports null and [unknown] when the directory is not a git repository", async () => {
@@ -344,7 +356,12 @@ describe("info reports the repository context", () => {
344356
await execFileAsync("git", ["init"], { cwd });
345357
await execFileAsync(
346358
"git",
347-
["remote", "add", "origin", "https://gitlab.com/acme/widgets.git"],
359+
[
360+
"remote",
361+
"add",
362+
"origin",
363+
"https://gitlab.com/__taskless_test__/widgets.git",
364+
],
348365
{ cwd }
349366
);
350367
const info = await readInfo();
@@ -358,7 +375,12 @@ describe("info reports the repository context", () => {
358375
await execFileAsync("git", ["init"], { cwd });
359376
await execFileAsync(
360377
"git",
361-
["remote", "add", "origin", "https://github.com/acme/widgets.git"],
378+
[
379+
"remote",
380+
"add",
381+
"origin",
382+
"https://github.com/__taskless_test__/widgets.git",
383+
],
362384
{ cwd }
363385
);
364386
const result = await runCli(["info", "--anonymous", "--json", "-d", cwd]);
@@ -368,7 +390,7 @@ describe("info reports the repository context", () => {
368390
ghOwner: string;
369391
};
370392
expect(info.loggedIn).toBe(false);
371-
expect(info.ghOwner).toBe("acme");
393+
expect(info.ghOwner).toBe("__taskless_test__");
372394
});
373395
});
374396

‎packages/cli/test/api-v2.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
} from "../src/api/v2";
1414
import { CLI_VERSION, CLI_VERSION_HEADER } from "../src/version";
1515

16-
const REPO = "https://github.com/acme/app";
16+
const REPO = "https://github.com/__taskless_test__/app";
1717

1818
const SERVED = {
1919
ruleId: "no-eval-3fa9c21b",

‎packages/cli/test/auth-status.test.ts‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ const identity: WhoamiResult = {
99
{
1010
orgId: 1,
1111
id: "00000000-0000-0000-0000-000000000001",
12-
name: "acme",
12+
name: "__taskless_test__",
1313
source: "github",
14-
url: "https://github.com/acme",
14+
url: "https://github.com/__taskless_test__",
1515
},
1616
],
1717
};
@@ -34,15 +34,15 @@ afterEach(() => {
3434
describe("describeAuthStatus", () => {
3535
it("names the user and orgs for an accepted saved token", () => {
3636
expect(describeAuthStatus({ status: "ok", data: identity })).toEqual([
37-
"Logged in as someone (acme).",
37+
"Logged in as someone (__taskless_test__).",
3838
]);
3939
});
4040

4141
it("says when the token comes from TASKLESS_TOKEN", () => {
4242
process.env.TASKLESS_TOKEN = "env-token";
4343

4444
expect(describeAuthStatus({ status: "ok", data: identity })).toEqual([
45-
"Logged in as someone (acme) via TASKLESS_TOKEN.",
45+
"Logged in as someone (__taskless_test__) via TASKLESS_TOKEN.",
4646
]);
4747
});
4848

‎packages/cli/test/entitlement.test.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { describe, expect, it } from "vitest";
22

33
import { parseEntitlementV2 } from "../src/api/entitlement";
44

5-
const UPGRADE = "https://app.taskless.io/o/acme/upgrade?from=reconcile";
5+
const UPGRADE =
6+
"https://app.taskless.io/o/__taskless_test__/upgrade?from=reconcile";
67

78
describe("parseEntitlementV2", () => {
89
it("keeps every withheld rule, which the v1 parser dropped (#403)", () => {
@@ -58,7 +59,7 @@ describe("parseEntitlementV2", () => {
5859

5960
it("keeps an upgrade URL only when it is absolute https", () => {
6061
for (const upgradeUrl of [
61-
"/o/acme/upgrade",
62+
"/o/__taskless_test__/upgrade",
6263
"http://app.taskless.io/x",
6364
"nope",
6465
]) {

‎packages/cli/test/error-envelope.test.ts‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,9 @@ describe("resolveIdentity failure codes (--json)", () => {
423423

424424
describe("origin 3: origin remote is not GitHub", () => {
425425
it("emits UNSUPPORTED_REMOTE_HOST from rule create", async () => {
426-
await initRepoWithOrigin("https://gitlab.com/acme/widgets.git");
426+
await initRepoWithOrigin(
427+
"https://gitlab.com/__taskless_test__/widgets.git"
428+
);
427429
const from = await writeCreateInput();
428430
const result = await runCli(
429431
["rule", "create", "--from", from, "--json", "-d", cwd],
@@ -434,7 +436,9 @@ describe("resolveIdentity failure codes (--json)", () => {
434436
});
435437

436438
it("emits UNSUPPORTED_REMOTE_HOST from rule improve", async () => {
437-
await initRepoWithOrigin("git@gitea.example.com:acme/widgets.git");
439+
await initRepoWithOrigin(
440+
"git@gitea.example.com:__taskless_test__/widgets.git"
441+
);
438442
const from = await writeImproveInput();
439443
const result = await runCli(
440444
["rule", "improve", "--from", from, "--json", "-d", cwd],
@@ -479,7 +483,12 @@ describe("resolveIdentity failure codes (--json)", () => {
479483

480484
await execFileAsync(
481485
"git",
482-
["remote", "add", "origin", "https://gitlab.com/acme/widgets.git"],
486+
[
487+
"remote",
488+
"add",
489+
"origin",
490+
"https://gitlab.com/__taskless_test__/widgets.git",
491+
],
483492
{ cwd }
484493
);
485494
const notGitHubRun = await runCli(args, withToken);

‎packages/cli/test/git-remote-context.test.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,14 @@ describe("resolveRepositoryContext never throws", () => {
7171
// cases above are not passing merely because nothing works under mock.
7272
mockedExecFile.mockImplementation(((..._arguments: unknown[]): unknown => {
7373
const callback = _arguments.at(-1) as ExecFileCallback;
74-
callback(null, "git@github.com:acme/widgets.git\n", "");
74+
callback(null, "git@github.com:__taskless_test__/widgets.git\n", "");
7575
return undefined;
7676
}) as unknown as typeof execFile);
7777

7878
const context = await resolveRepositoryContext("/any/path");
79-
expect(context.repositoryUrl).toBe("https://github.com/acme/widgets");
80-
expect(context.ghOwner).toBe("acme");
79+
expect(context.repositoryUrl).toBe(
80+
"https://github.com/__taskless_test__/widgets"
81+
);
82+
expect(context.ghOwner).toBe("__taskless_test__");
8183
});
8284
});

‎packages/cli/test/git-remote.test.ts‎

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -70,26 +70,28 @@ describe("canonicalOwnerUrl", () => {
7070
// two are compared with `===`, so every form here MUST reduce identically —
7171
// including the ssh://, git://, and port forms the old regex version threw on.
7272
it.each([
73-
"git@github.com:Acme/Widgets.git", // scp-like SSH
74-
"https://github.com/acme/widgets", // https
75-
"https://github.com/ACME/widgets.git", // .git suffix
76-
"https://www.github.com/acme/widgets/", // www. + trailing slash
77-
"git@github.com:acme/widgets", // scp-like, no .git
78-
"ssh://git@github.com/acme/widgets.git", // ssh:// URL form
79-
"git://github.com/acme/widgets.git", // git:// URL form
80-
"https://github.com:443/acme/widgets", // explicit port
81-
"https://x-access-token@GitHub.com/Acme/Widgets", // userinfo + mixed case
82-
"acme", // bare owner login (the form the server canonicalizes)
73+
"git@github.com:__Taskless_Test__/Widgets.git", // scp-like SSH
74+
"https://github.com/__taskless_test__/widgets", // https
75+
"https://github.com/__TASKLESS_TEST__/widgets.git", // .git suffix
76+
"https://www.github.com/__taskless_test__/widgets/", // www. + trailing slash
77+
"git@github.com:__taskless_test__/widgets", // scp-like, no .git
78+
"ssh://git@github.com/__taskless_test__/widgets.git", // ssh:// URL form
79+
"git://github.com/__taskless_test__/widgets.git", // git:// URL form
80+
"https://github.com:443/__taskless_test__/widgets", // explicit port
81+
"https://x-access-token@GitHub.com/__Taskless_Test__/Widgets", // userinfo + mixed case
82+
"__taskless_test__", // bare owner login (the form the server canonicalizes)
8383
])("reduces %s to the canonical owner url", (input) => {
84-
expect(canonicalOwnerUrl(input)).toBe("https://github.com/acme");
84+
expect(canonicalOwnerUrl(input)).toBe(
85+
"https://github.com/__taskless_test__"
86+
);
8587
});
8688

8789
it("keeps the host for non-GitHub remotes (dropped later by listRemoteOwnerUrls)", () => {
8890
// Mirrors the server: host-agnostic and never throws. A gitlab owner url
8991
// just won't match a github-sourced org.
90-
expect(canonicalOwnerUrl("git@gitlab.com:acme/widgets.git")).toBe(
91-
"https://gitlab.com/acme"
92-
);
92+
expect(
93+
canonicalOwnerUrl("git@gitlab.com:__taskless_test__/widgets.git")
94+
).toBe("https://gitlab.com/__taskless_test__");
9395
});
9496
});
9597

@@ -111,7 +113,12 @@ describe("listRemoteOwnerUrls", () => {
111113
);
112114
await execFileAsync(
113115
"git",
114-
["remote", "add", "upstream", "https://github.com/acme/widgets.git"],
116+
[
117+
"remote",
118+
"add",
119+
"upstream",
120+
"https://github.com/__taskless_test__/widgets.git",
121+
],
115122
{ cwd: directory }
116123
);
117124
await execFileAsync(
@@ -121,7 +128,7 @@ describe("listRemoteOwnerUrls", () => {
121128
);
122129
expect(await listRemoteOwnerUrls(directory)).toEqual([
123130
"https://github.com/origin-org",
124-
"https://github.com/acme",
131+
"https://github.com/__taskless_test__",
125132
"https://github.com/me",
126133
]);
127134
});
@@ -130,7 +137,12 @@ describe("listRemoteOwnerUrls", () => {
130137
expect(await listRemoteOwnerUrls(directory)).toEqual([]);
131138
await execFileAsync(
132139
"git",
133-
["remote", "add", "origin", "git@gitlab.com:acme/widgets.git"],
140+
[
141+
"remote",
142+
"add",
143+
"origin",
144+
"git@gitlab.com:__taskless_test__/widgets.git",
145+
],
134146
{ cwd: directory }
135147
);
136148
expect(await listRemoteOwnerUrls(directory)).toEqual([]);
@@ -166,11 +178,16 @@ describe("listRemoteOwnerUrls", () => {
166178
// this repo would have resolved to no current-org context.
167179
await execFileAsync(
168180
"git",
169-
["remote", "add", "origin", "ssh://git@github.com/Acme/Widgets.git"],
181+
[
182+
"remote",
183+
"add",
184+
"origin",
185+
"ssh://git@github.com/__Taskless_Test__/Widgets.git",
186+
],
170187
{ cwd: directory }
171188
);
172189
expect(await listRemoteOwnerUrls(directory)).toEqual([
173-
"https://github.com/acme",
190+
"https://github.com/__taskless_test__",
174191
]);
175192
});
176193
});

0 commit comments

Comments
 (0)