Initial curated projectbrain source from 8a7b1e0651dbdab97d744cbd2e653ab3970ac6c5

This commit is contained in:
Public Source Publisher committed 2026-10-01 01:43:26 +02:00
commit 5aa3e8d685
700 files changed
+132801

No files matched your search

+48
View File
@@ -0,0 +1,48 @@
import { describe, expect, it } from "vitest";
import {
assertExplicitRepositoryTransfer,
assertRepositoryTransferHasNoDeliveryHistory,
GiteaRepositoryOwnershipConflictError,
GiteaRepositoryTransferBlockedError,
} from "../src/integrations/gitea/service.js";
import { integrationError } from "../src/routes/giteaIntegration.js";
describe("Gitea repository ownership", () => {
const existing = { projectId: "project-a", project: { name: "Project A" } };
it("blocks a silent move to another project with an HTTP 409 conflict", () => {
let conflict: unknown;
try {
assertExplicitRepositoryTransfer(existing, "project-b", "Acme/platform", false);
} catch (error) {
conflict = error;
}
expect(conflict).toBeInstanceOf(GiteaRepositoryOwnershipConflictError);
expect(integrationError(conflict)).toMatchObject({
status: 409,
code: "GITEA_REPOSITORY_ALREADY_LINKED",
});
});
it("allows same-project updates and an explicitly confirmed transfer", () => {
expect(() => assertExplicitRepositoryTransfer(existing, "project-a", "Acme/platform", false)).not.toThrow();
expect(() => assertExplicitRepositoryTransfer(existing, "project-b", "Acme/platform", true)).not.toThrow();
});
it("blocks even an explicit transfer when delivery history would cross project boundaries", () => {
let conflict: unknown;
try {
assertRepositoryTransferHasNoDeliveryHistory("Acme/platform", 2);
} catch (error) {
conflict = error;
}
expect(conflict).toBeInstanceOf(GiteaRepositoryTransferBlockedError);
expect(integrationError(conflict)).toMatchObject({
status: 409,
code: "GITEA_REPOSITORY_TRANSFER_BLOCKED",
});
expect(() => assertRepositoryTransferHasNoDeliveryHistory("Acme/platform", 0)).not.toThrow();
});
});