test(release-cleanup): 補上結束碼、sanitizeBody 與 logger 輸出測試
新增子行程驗證 index.js 失敗時以非零狀態結束、fetchAllPages 錯誤訊息 清理控制字元與長度限制、以及 logger 各輸出函式格式與 stdout/stderr 分流測試。 測試共 56 項全數通過。 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
87db9030d6
commit
826b559006
@@ -1,5 +1,7 @@
|
||||
import { test, afterEach } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { spawnSync } from 'node:child_process'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { main } from '../index.js'
|
||||
|
||||
const realFetch = globalThis.fetch
|
||||
@@ -41,3 +43,14 @@ test('main 在必填環境變數缺失時 reject(供整合層級驗證錯誤處
|
||||
})
|
||||
await assert.rejects(() => main(), /GITEA_SERVER_URL is required/)
|
||||
})
|
||||
|
||||
test('直接執行 index.js 在設定錯誤時以非零狀態碼結束', () => {
|
||||
const indexPath = fileURLToPath(new URL('../index.js', import.meta.url))
|
||||
// 僅帶 PATH,不提供任何必填環境變數,使 main 拋錯並觸發 process.exit(1)
|
||||
const result = spawnSync(process.execPath, [indexPath], {
|
||||
env: { PATH: process.env.PATH },
|
||||
encoding: 'utf8',
|
||||
})
|
||||
assert.equal(result.status, 1)
|
||||
assert.match(result.stderr, /GITEA_SERVER_URL is required/)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user