test(release-cleanup): 補強逾時、非陣列、token 邊界與 failError 測試
新增 fetchAllPages 的 AbortError 逾時與非陣列回應測試、loadConfig 的 GITEA_TOKEN 邊界測試,以及 logger.failError 測試。測試共 47 項全數通過。 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
f6d2ebeab2
commit
b9d7c4e970
@@ -90,6 +90,28 @@ test('fetchAllPages 在回應非 JSON 時丟出例外', async () => {
|
||||
)
|
||||
})
|
||||
|
||||
test('fetchAllPages 在回應為非陣列 JSON 時丟出例外', async () => {
|
||||
globalThis.fetch = async () => jsonResponse({ message: 'error object' })
|
||||
const client = new GiteaClient({})
|
||||
await assert.rejects(
|
||||
() => client.fetchAllPages('https://example.com/api'),
|
||||
/non-array JSON payload/,
|
||||
)
|
||||
})
|
||||
|
||||
test('fetchAllPages 在 fetch 因逾時拋出 AbortError 時向外拋出', async () => {
|
||||
globalThis.fetch = async () => {
|
||||
const err = new Error('The operation was aborted due to timeout')
|
||||
err.name = 'AbortError'
|
||||
throw err
|
||||
}
|
||||
const client = new GiteaClient({})
|
||||
await assert.rejects(
|
||||
() => client.fetchAllPages('https://example.com/api'),
|
||||
(err) => err.name === 'AbortError',
|
||||
)
|
||||
})
|
||||
|
||||
test('deleteResource 回傳 HTTP 狀態碼', async () => {
|
||||
globalThis.fetch = async (url, opts) => {
|
||||
assert.equal(opts.method, 'DELETE')
|
||||
|
||||
Reference in New Issue
Block a user