Publish curated projectbrain source from 0244fbf232898e6dc076ff2159d96a6da55ab5b5
This commit is contained in:
1 parent
eca2891b07
commit
d5c9615684
10 files changed
+170
-31
No files matched your search
@@ -0,0 +1,36 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { giteaMergeCompatibility } from "../src/integrations/gitea/compatibility.js";
|
||||
import { GiteaClient } from "../src/integrations/gitea/client.js";
|
||||
|
||||
describe("upstream Gitea merge negotiation", () => {
|
||||
it.each(["28.0.0", "v28.0.0", "28.0.0+gitea.build-123", " v1.27.3+build.42 ", "1.25.0"])("accepts attested stable version %s", (value) => {
|
||||
expect(giteaMergeCompatibility(value)).toMatchObject({ supported: true });
|
||||
});
|
||||
it.each([undefined, null, {}, 28, "", "1.24.9", "29.0.0", "2.0.0", "28.0", "028.0.0", "28.0.0+", "28.0.0+bad/metadata", "28.0.0-rc.1", "28.0.0-garbage suffix", "28.0.0+" + "a".repeat(128)])("fails closed for %s", (value) => {
|
||||
expect(giteaMergeCompatibility(value).supported).toBe(false);
|
||||
});
|
||||
it("does not accept a connector version in place of the upstream version", async () => {
|
||||
const fetcher = vi.fn(async () => new Response(JSON.stringify({ connectorVersion: "28.0.0", version: "1.24.9" })));
|
||||
const client = new GiteaClient("https://gitea.example.com", "test-token", fetcher as typeof fetch);
|
||||
expect(await client.getUpstreamCompatibility()).toMatchObject({ supported: false, source: "upstream:/api/v1/version", normalizedVersion: "1.24.9" });
|
||||
});
|
||||
it("uses current upstream 28 when connector build is 1.14", async () => {
|
||||
const fetcher = vi.fn(async () => new Response(JSON.stringify({ connectorVersion: "1.14.0", version: "28.0.0" })));
|
||||
const client = new GiteaClient("https://gitea.example.com", "test-token", fetcher as typeof fetch);
|
||||
expect(await client.getUpstreamCompatibility()).toMatchObject({ supported: true, normalizedVersion: "28.0.0", strategyKey: "do" });
|
||||
});
|
||||
it("re-negotiates before each merge and blocks an unsupported server upgrade", async () => {
|
||||
let version = "28.0.0";
|
||||
let writes = 0;
|
||||
const fetcher = vi.fn(async (input: string | URL | Request) => {
|
||||
if (String(input).endsWith("/version")) return new Response(JSON.stringify({ version }));
|
||||
writes += 1;
|
||||
return new Response(null, { status: 204 });
|
||||
});
|
||||
const client = new GiteaClient("https://gitea.example.com", "test-token", fetcher as typeof fetch);
|
||||
await client.mergePullRequest("Jens", "canary", 1, { method: "squash", headCommitId: "a".repeat(40) });
|
||||
version = "29.0.0";
|
||||
await expect(client.mergePullRequest("Jens", "canary", 1, { method: "squash", headCommitId: "a".repeat(40) })).rejects.toMatchObject({ code: "GITEA_VERSION_UNSUPPORTED" });
|
||||
expect(writes).toBe(1);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user