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
@@ -103,6 +103,28 @@ test('cleanupReleases 對 id 進行 URL 編碼(防路徑穿越)', async () => {
|
||||
assert.deepEqual(client.deleted, ['http://x/releases/..%2Fevil'])
|
||||
})
|
||||
|
||||
test('cleanupReleases 在刪除回傳非 204 時記錄錯誤至 stderr', async () => {
|
||||
const client = fakeClient(
|
||||
[
|
||||
{ id: 1, tag_name: 'v1', name: 'n1', created_at: '2024-01-01T00:00:00Z' },
|
||||
{ id: 2, tag_name: 'v2', name: 'n2', created_at: '2024-02-01T00:00:00Z' },
|
||||
],
|
||||
() => 500,
|
||||
)
|
||||
const realWrite = process.stderr.write
|
||||
const chunks = []
|
||||
process.stderr.write = (chunk) => {
|
||||
chunks.push(String(chunk))
|
||||
return true
|
||||
}
|
||||
try {
|
||||
await cleanupReleases(client, { releaseApiUrl: 'http://x/releases', keepCount: 1 })
|
||||
} finally {
|
||||
process.stderr.write = realWrite
|
||||
}
|
||||
assert.match(chunks.join(''), /\[ERR\]/)
|
||||
})
|
||||
|
||||
test('cleanupReleases 略過沒有 id 的 release', async () => {
|
||||
const client = fakeClient([
|
||||
{ id: 1, tag_name: 'v3', name: 'n3', created_at: '2024-03-01T00:00:00Z' },
|
||||
|
||||
Reference in New Issue
Block a user