test(src/index): 補齊失敗路徑輸出測試

This commit is contained in:
2026-07-11 10:08:55 +00:00
parent 768ab84b00
commit 6ee9195f52
+26
View File
@@ -0,0 +1,26 @@
const assert = require('node:assert/strict');
const { spawnSync } = require('node:child_process');
const path = require('node:path');
const test = require('node:test');
test('主流程失敗時會輸出階段前綴與錯誤碼', () => {
const result = spawnSync(
process.execPath,
[path.join(__dirname, 'index.js')],
{
cwd: path.join(__dirname, '..'),
env: {
...process.env,
GITEA_SERVER_URL: '',
GITEA_REPOSITORY: 'owner/repo',
RUNNER_TOKEN: 'token',
IS_BETA: 'false',
},
encoding: 'utf8',
},
);
assert.equal(result.status, 1);
assert.match(result.stderr, /^\[參數檢查\]\[ERR\]\[\d{4}\/\d{2}\/\d{2} /);
assert.match(result.stderr, /GITEA_SERVER_URL 未設定/);
});