test(release-cleanup): 補上 MAX_PAGES 邊界與刪除失敗記錄測試
新增 fetchAllPages 於第 MAX_PAGES 頁回空陣列時正常結束的測試,以及 cleanupReleases/cleanupOrphanTags 在 deleteResource 回非 204 時繼續處理 並寫入 stderr 錯誤記錄的測試。測試共 59 項全數通過。 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
76bccfeea9
commit
fd2dfa8732
@@ -142,6 +142,18 @@ test('fetchAllPages 的錯誤訊息會清理控制字元並限制長度(sanitize
|
||||
assert.ok((message.match(/x/g) || []).length <= 200)
|
||||
})
|
||||
|
||||
test('fetchAllPages 在第 MAX_PAGES 頁回傳空陣列時正常結束(不拋例外)', async () => {
|
||||
let page = 0
|
||||
globalThis.fetch = async () => {
|
||||
page += 1
|
||||
// 前 999 頁有資料,第 1000 頁(MAX_PAGES)回空陣列,應正常結束
|
||||
return jsonResponse(page < 1000 ? [{ id: page }] : [])
|
||||
}
|
||||
const client = new GiteaClient({})
|
||||
const items = await client.fetchAllPages('https://example.com/api')
|
||||
assert.equal(items.length, 999)
|
||||
})
|
||||
|
||||
test('deleteResource 回傳 HTTP 狀態碼', async () => {
|
||||
globalThis.fetch = async (url, opts) => {
|
||||
assert.equal(opts.method, 'DELETE')
|
||||
|
||||
Reference in New Issue
Block a user