Files
orca/src/shared/hermes-run-ref-retention.test.ts
T
NeilandOrca 879aad7dd6 oom(foundation): bound shared readers/limits + add BoundedMap primitive (#10299)
* oom(01): A1-shared-readers — reintroduce #10179 subset

Files: 18 applied, 0 deleted (from 6eb70d8370)

Co-authored-by: Orca <help@stably.ai>

* oom(02): A2-shared-image-media — reintroduce #10179 subset

Files: 7 applied, 0 deleted (from 6eb70d8370)

Co-authored-by: Orca <help@stably.ai>

* oom(03): A3-shared-fs-listing — reintroduce #10179 subset

Files: 21 applied, 0 deleted (from 6eb70d8370)

Co-authored-by: Orca <help@stably.ai>

* oom(04): A4-shared-remote-relay — reintroduce #10179 subset

Files: 8 applied, 0 deleted (from 6eb70d8370)

Co-authored-by: Orca <help@stably.ai>

* oom(05): A5-shared-misc — reintroduce #10179 subset

Files: 28 applied, 0 deleted (from 6eb70d8370)

Co-authored-by: Orca <help@stably.ai>

* oom(06): B-shared-wiring — reintroduce #10179 subset

Files: 81 applied, 0 deleted (from 6eb70d8370)

Co-authored-by: Orca <help@stably.ai>

---------

Co-authored-by: Orca <help@stably.ai>
2026-07-24 21:36:57 -07:00

37 lines
1.3 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { HermesRunRefRetainer } from './hermes-run-ref-retention'
describe('HermesRunRefRetainer', () => {
it('preserves every ref and exact order below the limit', () => {
const retainer = new HermesRunRefRetainer<{ id: string; run_at: string }>(3)
retainer.add({ id: 'middle', run_at: '2026-05-15T09:00:00Z' })
retainer.add({ id: 'newest', run_at: '2026-05-16T09:00:00Z' })
retainer.add({ id: 'oldest', run_at: '2026-05-14T09:00:00Z' })
expect(retainer.finish()).toEqual({
refs: [
{ id: 'newest', run_at: '2026-05-16T09:00:00Z' },
{ id: 'middle', run_at: '2026-05-15T09:00:00Z' },
{ id: 'oldest', run_at: '2026-05-14T09:00:00Z' }
],
saturated: false
})
})
it('retains the exact newest window and reports saturation', () => {
const retainer = new HermesRunRefRetainer<{ id: string; run_at: string }>(3)
for (const day of [1, 5, 2, 6, 3, 4]) {
retainer.add({ id: `day-${day}`, run_at: `2026-05-0${day}T09:00:00Z` })
}
expect(retainer.finish()).toEqual({
refs: [
{ id: 'day-6', run_at: '2026-05-06T09:00:00Z' },
{ id: 'day-5', run_at: '2026-05-05T09:00:00Z' },
{ id: 'day-4', run_at: '2026-05-04T09:00:00Z' }
],
saturated: true
})
})
})