test: cover review edge cases and repair paths
This commit is contained in:
+13
-1
@@ -1,4 +1,4 @@
|
||||
import { describe, it, before, after, beforeEach } from 'node:test';
|
||||
import { describe, it, before, after, beforeEach, mock } from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'fs';
|
||||
import os from 'os';
|
||||
@@ -89,6 +89,18 @@ describe('commitAndPush', () => {
|
||||
const failSpawn = () => ({ status: 1, stdout: '', stderr: 'fatal: error', error: null });
|
||||
await assert.doesNotReject(() => commitAndPush(workspace, path.join(workspace, 'repo'), failSpawn));
|
||||
});
|
||||
|
||||
it('logs failure when git command fails', async () => {
|
||||
const failSpawn = () => ({ status: 1, stdout: '', stderr: 'fatal: error', error: null });
|
||||
const logs = [];
|
||||
mock.method(console, 'log', (...args) => { logs.push(args.join(' ')); });
|
||||
try {
|
||||
await commitAndPush(workspace, path.join(workspace, 'repo'), failSpawn);
|
||||
assert.ok(logs.some(line => line.includes('Runner failed: commit/push 失敗')), 'expected failure log');
|
||||
} finally {
|
||||
mock.restoreAll();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('cloneRepo', () => {
|
||||
|
||||
Reference in New Issue
Block a user