diff --git a/app/test/git.test.js b/app/test/git.test.js index a4b4965..9d9b151 100644 --- a/app/test/git.test.js +++ b/app/test/git.test.js @@ -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', () => {