test(release-cleanup): 補上一般網路錯誤與空陣列邊界測試
新增 fetchAllPages 在 fetch 拋一般網路錯誤時向外拋出的測試,以及 selectReleasesToDelete 對空陣列回傳空陣列的測試。測試共 67 項全數通過。 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
f1fce4b6e4
commit
1f615fee90
@@ -112,6 +112,17 @@ test('fetchAllPages 在 fetch 因逾時拋出 AbortError 時向外拋出', async
|
||||
)
|
||||
})
|
||||
|
||||
test('fetchAllPages 在 fetch 拋出一般網路錯誤時向外拋出', async () => {
|
||||
globalThis.fetch = async () => {
|
||||
throw new TypeError('fetch failed: ECONNREFUSED')
|
||||
}
|
||||
const client = new GiteaClient({})
|
||||
await assert.rejects(
|
||||
() => client.fetchAllPages('https://example.com/api'),
|
||||
/fetch failed|ECONNREFUSED/,
|
||||
)
|
||||
})
|
||||
|
||||
test('fetchAllPages 在頁數超過 MAX_PAGES 時中止以避免無限迴圈', async () => {
|
||||
// 永遠回傳非空陣列,模擬 API 不以空陣列結尾的異常情形
|
||||
globalThis.fetch = async () => jsonResponse([{ id: 1 }])
|
||||
|
||||
Reference in New Issue
Block a user