test(release-cleanup): 補上異常結構 release 與 fetchAllPages 失敗測試
新增 cleanupReleases 處理 null/缺欄位 release 不拋例外的測試,以及 cleanupOrphanTags 在 fetchAllPages 拋錯時向外拋出的測試。測試共 64 項全數通過。 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
24bcad7141
commit
9a71e2d09d
@@ -140,6 +140,20 @@ test('cleanupReleases 在刪除回傳非 204 時記錄錯誤至 stderr', async (
|
||||
assert.match(chunks.join(''), /\[ERR\]/)
|
||||
})
|
||||
|
||||
test('cleanupReleases 對含 null/異常結構的 release 不拋例外且照常處理正常項目', async () => {
|
||||
const client = fakeClient([
|
||||
{ id: 3, tag_name: 'v3', name: 'n3', created_at: '2024-03-01T00:00:00Z' },
|
||||
null,
|
||||
{ created_at: '2024-02-01T00:00:00Z' }, // 缺 id/tag_name
|
||||
{ id: 1, tag_name: 'v1', name: 'n1', created_at: '2024-01-01T00:00:00Z' },
|
||||
])
|
||||
await assert.doesNotReject(() =>
|
||||
cleanupReleases(client, { releaseApiUrl: 'http://x/releases', keepCount: 1 }),
|
||||
)
|
||||
// 保留最新(id=3);待刪除者中僅 id=1 為有效正整數 id,其餘(null、缺 id)被略過
|
||||
assert.deepEqual(client.deleted, ['http://x/releases/1'])
|
||||
})
|
||||
|
||||
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