test(release-cleanup): 補上 MAX_PAGES 與刪除 URL 編碼測試

新增 fetchAllPages 超過 MAX_PAGES 中止的測試,以及 cleanupReleases/
cleanupOrphanTags 對含 ../ 的 id/tag 名稱編碼的測試。測試共 50 項全數通過。

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jeffery
2026-06-26 11:21:56 +08:00
co-authored by Claude Opus 4.8
parent aa4f6364e2
commit 0ba93a40a9
3 changed files with 30 additions and 0 deletions
+10
View File
@@ -112,6 +112,16 @@ test('fetchAllPages 在 fetch 因逾時拋出 AbortError 時向外拋出', async
)
})
test('fetchAllPages 在頁數超過 MAX_PAGES 時中止以避免無限迴圈', async () => {
// 永遠回傳非空陣列,模擬 API 不以空陣列結尾的異常情形
globalThis.fetch = async () => jsonResponse([{ id: 1 }])
const client = new GiteaClient({})
await assert.rejects(
() => client.fetchAllPages('https://example.com/api'),
/exceeded MAX_PAGES/,
)
})
test('deleteResource 回傳 HTTP 狀態碼', async () => {
globalThis.fetch = async (url, opts) => {
assert.equal(opts.method, 'DELETE')