Commit5164fabunknown_key
fix(tests): green the suite — drop stale BLK-016 Bearer test, harden git-repo test
fix(tests): green the suite — drop stale BLK-016 Bearer test, harden git-repo test
Suite was at 1256 pass / 4 fail; now 1256 / 0 across three consecutive runs.
1) crontech-deploy.test.ts:
"sends Authorization: Bearer <secret>..." was stale on two counts:
- Name asserts Bearer auth, but BUILD_BIBLE §7 documents that the
Crontech sender was rewritten to HMAC-SHA256 in X-Gluecron-Signature
(no Bearer). HMAC contract is covered by the neighbour at line 177.
- Body referenced an undefined `installFetchCapture` plus bare `after`,
`before`, `fn` symbols — a leftover refactor artifact.
Retitled to its actual subject (the GitHub-shaped push payload) and
wired it up to the real `captureFetch` helper.
2) git-repository.test.ts:
"with commits" sub-suite passed solo but failed in the full run. Root
cause: other test files (notably import-verify.test.ts:57) mutate
process.env.GIT_REPOS_PATH at module top level, so by the time the
inner beforeAll runs the env value is non-deterministic. Defensively
re-pin GIT_REPOS_PATH = TEST_REPOS at the top of that beforeAll, and
surface non-zero git exit codes from the local `run` helper so the
next regression of this shape fails loudly instead of silently.2 files changed+17−45164fab3b751a32fe5fb23129499a9d1fc5a7093
2 changed files+17−4
Modifiedsrc/__tests__/crontech-deploy.test.ts+4−3View fileUnifiedSplit
@@ -143,9 +143,10 @@ describe("hooks/post-receive — triggerCrontechDeploy (BLK-016 sender)", () =>
143143 expect(calls[0]!.init.method).toBe("POST");
144144 });
145145
146 it("sends Authorization: Bearer <secret> when GLUECRON_WEBHOOK_SECRET is set", async () => {
147 process.env.GLUECRON_WEBHOOK_SECRET = "webhook-test-value";
148 const calls = installFetchCapture();
146 it("posts a GitHub-shaped push payload (event, repository, ref, before/after, pusher, commits, sent_at, source)", async () => {
147 const after = "b".repeat(40);
148 const before = "c".repeat(40);
149 const { calls, fn } = captureFetch();
149150
150151 await triggerCrontechDeploy(
151152 makeArgs({
Modifiedsrc/__tests__/git-repository.test.ts+13−1View fileUnifiedSplit
@@ -61,13 +61,25 @@ describe("git repository management", () => {
6161
6262 describe("with commits", () => {
6363 beforeAll(async () => {
64 // Re-pin env here: other test files mutate GIT_REPOS_PATH at module top level
65 // (e.g. import-verify.test.ts), so the env value at this point in the run
66 // is non-deterministic. Resolve to TEST_REPOS for this describe block.
67 process.env.GIT_REPOS_PATH = TEST_REPOS;
6468 const cloneDir = join(TEST_REPOS, "_clone_tmp");
6569 await mkdir(cloneDir, { recursive: true });
6670 const repoPath = getRepoPath(owner, repo);
6771
6872 const run = async (cmd: string[], cwd: string) => {
6973 const proc = Bun.spawn(cmd, { cwd, stdout: "pipe", stderr: "pipe" });
70 await proc.exited;
74 const [exitCode, stderr] = await Promise.all([
75 proc.exited,
76 new Response(proc.stderr).text(),
77 ]);
78 if (exitCode !== 0) {
79 throw new Error(
80 `git command failed (${exitCode}): ${cmd.join(" ")}\nstderr: ${stderr}`
81 );
82 }
7183 };
7284
7385 const workDir = join(cloneDir, "work");
7486