Skip to content

Commit 2f8c235

Browse files
committed
test(source-control): cover shared HTTP authority resolution
1 parent d992adc commit 2f8c235

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

‎packages/client-runtime/src/sourceControlClients.test.ts‎

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -316,10 +316,20 @@ describe("sourceControlClients project hosts", () => {
316316
locator: { remoteUrl: "http://forge.example:3000/team/repo.git" },
317317
};
318318

319-
it("keeps an HTTP remote's port for Forgejo only, and falls back to the kind without a key", () => {
320-
expect(sourceControlClients.changeRequestHost(identity, "forgejo")).toBe("forge.example:3000");
321-
expect(sourceControlClients.changeRequestHost(identity, "gitlab")).toBe("forge.example");
322-
expect(sourceControlClients.changeRequestHost(identity, undefined)).toBe("forge.example");
319+
it("keeps matching HTTP web ports and falls back to the kind without a key", () => {
320+
for (const kind of ["forgejo", "github", "gitlab", undefined] as const) {
321+
expect(sourceControlClients.changeRequestHost(identity, kind)).toBe("forge.example:3000");
322+
}
323+
for (const kind of ["github", "gitlab", undefined] as const) {
324+
for (const remoteUrl of [
325+
"ssh://[email protected]:2222/team/repo.git",
326+
"http://other.example:3000/team/repo.git",
327+
]) {
328+
expect(
329+
sourceControlClients.changeRequestHost({ ...identity, locator: { remoteUrl } }, kind),
330+
).toBe("forge.example");
331+
}
332+
}
323333
expect(
324334
sourceControlClients.changeRequestHost(
325335
{ locator: { remoteUrl: "https://x.example/a/b" } },

0 commit comments

Comments
 (0)