test(git): 補 commitAndPush 在 push 失敗時不中斷流程的測試

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jeffery
2026-06-26 15:26:08 +08:00
co-authored by Claude Opus 4.8
parent 998b5ca5ac
commit f0a42cd98d
+17
View File
@@ -208,6 +208,23 @@ describe('commitAndPush', () => {
assert.ok(logs.some(line => line.includes('Step8 commit 成功但 push 失敗')));
assert.ok(logs.some(line => line.includes('pre-receive hook declined')));
});
it('does not throw and does not mistake a failed push for success (commit still ran, push attempted)', async () => {
// commit 成功、僅 push 失敗:函式必須吞掉錯誤不中斷上層流程。
const spawn = makeSpawn({
push: () => ({ status: 1, stdout: '', stderr: 'fatal: unable to access remote', error: null }),
});
await assert.doesNotReject(
() => commitAndPush(workspace, path.join(workspace, 'repo'), spawn, sourceRoot),
'push failure must not crash the pipeline',
);
const commitCall = spawn.calls.find(c => c.args[0] === 'commit');
assert.ok(commitCall, 'commit should still run before the failed push');
const pushCall = spawn.calls.find(c => c.args[0] === 'push');
assert.ok(pushCall, 'push should have been attempted');
});
});
describe('cloneRepo', () => {