test: cover review edge cases and repair paths

This commit is contained in:
2026-05-13 06:23:45 +00:00
parent 8f413439b3
commit 3f3ead0f08
8 changed files with 243 additions and 41 deletions
+13 -1
View File
@@ -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', () => {