Files
DevRunbook-Public/packages/application/src/retention/artifact-retention.test.ts
T
DevRunbook release export cfd2804e27
Managed validation / full (push) Successful in 3m18s
Publish DevRunbook source
2026-09-03 04:09:17 +02:00

39 lines
1.0 KiB
TypeScript

import { describe, expect, it, vi } from 'vitest'
import { enforceArtifactRetention } from './artifact-retention'
describe('artifact retention', () => {
it('removes only store-selected expired bytes and finalizes their metadata', async () => {
const artifacts = [
{
id: 'artifact-1',
workspaceId: 'workspace-1',
storageKey: 'a'.repeat(64),
},
{
id: 'artifact-2',
workspaceId: 'workspace-1',
storageKey: 'b'.repeat(64),
},
]
const store = {
listExpired: vi.fn().mockResolvedValue(artifacts),
finalizeDeletion: vi.fn().mockResolvedValue(true),
}
const storage = {
deleteIfPresent: vi
.fn()
.mockResolvedValueOnce(true)
.mockResolvedValueOnce(false),
}
await expect(
enforceArtifactRetention({
store,
storage,
now: new Date('2026-07-27T12:00:00.000Z'),
}),
).resolves.toEqual({ scanned: 2, deleted: 1, missing: 1 })
expect(store.finalizeDeletion).toHaveBeenCalledTimes(2)
})
})