From 6ee9195f52069567243b62ee6887e5b44b009d95 Mon Sep 17 00:00:00 2001 From: Jeffery Date: Sat, 11 Jul 2026 10:08:55 +0000 Subject: [PATCH] =?UTF-8?q?test(src/index):=20=E8=A3=9C=E9=BD=8A=E5=A4=B1?= =?UTF-8?q?=E6=95=97=E8=B7=AF=E5=BE=91=E8=BC=B8=E5=87=BA=E6=B8=AC=E8=A9=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.test.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 src/index.test.js diff --git a/src/index.test.js b/src/index.test.js new file mode 100644 index 0000000..e655888 --- /dev/null +++ b/src/index.test.js @@ -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 未設定/); +});