test(src/index): 補齊失敗路徑輸出測試
This commit is contained in:
@@ -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 未設定/);
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user