fix: update integration branch test to match #300 behavior

writeIntegrationBranch now intentionally updates when the branch changes
(#300). Updated the stale "idempotent — doesn't overwrite" test to assert
the new behavior, and added a separate test for same-branch idempotency.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Lex Christopherson 2026-03-13 23:37:52 -06:00
parent ff1d7c5af9
commit 9298467ece

View file

@ -1429,17 +1429,32 @@ async function main(): Promise<void> {
rmSync(repo, { recursive: true, force: true });
}
// ─── writeIntegrationBranch: idempotent — doesn't overwrite ───────────
// ─── writeIntegrationBranch: updates when branch changes (#300) ──────
console.log("\n=== Integration branch: idempotent write ===");
console.log("\n=== Integration branch: updates on branch change ===");
{
const repo = initBranchTestRepo();
writeIntegrationBranch(repo, "M001", "f-123-first");
writeIntegrationBranch(repo, "M001", "f-456-second"); // should NOT overwrite
writeIntegrationBranch(repo, "M001", "f-456-second"); // updates to new branch (#300)
assertEq(readIntegrationBranch(repo, "M001"), "f-123-first", "second write does not overwrite existing integration branch");
assertEq(readIntegrationBranch(repo, "M001"), "f-456-second", "second write updates integration branch to new value");
rmSync(repo, { recursive: true, force: true });
}
// ─── writeIntegrationBranch: same branch is idempotent ─────────────────
console.log("\n=== Integration branch: same branch is idempotent ===");
{
const repo = initBranchTestRepo();
writeIntegrationBranch(repo, "M001", "f-123-first");
writeIntegrationBranch(repo, "M001", "f-123-first"); // same branch — no-op
assertEq(readIntegrationBranch(repo, "M001"), "f-123-first", "same branch write is idempotent");
rmSync(repo, { recursive: true, force: true });
}