fix(invariants): join package checks at startup
This commit is contained in:
@@ -12,24 +12,21 @@ export const name = 'retention-invariant'
|
||||
export const inject = ['invariants']
|
||||
|
||||
/** Assert exact head-retention accounting after the budget is exceeded. */
|
||||
const install: InvariantInstaller = (ctx, fail) => {
|
||||
ctx.effect(async () => {
|
||||
const { ItemRetainer } = await import('./index.ts')
|
||||
const retainer = new ItemRetainer<string>({ kind: 'head', maxItems: 2 })
|
||||
retainer.push('first')
|
||||
retainer.push('second')
|
||||
retainer.push('third')
|
||||
const result = retainer.finish()
|
||||
assertInvariant(fail,
|
||||
result.items.join(',') === 'first,second'
|
||||
&& result.seen === 3
|
||||
&& result.kept === 2
|
||||
&& result.truncated
|
||||
&& result.omitted.kind === 'exact'
|
||||
&& result.omitted.count === 1,
|
||||
'head retention must keep the prefix and report exact seen, kept, and omitted counts')
|
||||
return () => {}
|
||||
}, 'retention: validate exact head accounting')
|
||||
const install: InvariantInstaller = async (_ctx, fail) => {
|
||||
const { ItemRetainer } = await import('./index.ts')
|
||||
const retainer = new ItemRetainer<string>({ kind: 'head', maxItems: 2 })
|
||||
retainer.push('first')
|
||||
retainer.push('second')
|
||||
retainer.push('third')
|
||||
const result = retainer.finish()
|
||||
assertInvariant(fail,
|
||||
result.items.join(',') === 'first,second'
|
||||
&& result.seen === 3
|
||||
&& result.kept === 2
|
||||
&& result.truncated
|
||||
&& result.omitted.kind === 'exact'
|
||||
&& result.omitted.count === 1,
|
||||
'head retention must keep the prefix and report exact seen, kept, and omitted counts')
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user