33 lines
1.2 KiB
JavaScript
33 lines
1.2 KiB
JavaScript
import { describe, it, expect } from 'vitest';
|
|
import { mkdtempSync } from 'node:fs';
|
|
import { tmpdir } from 'node:os';
|
|
import { join } from 'node:path';
|
|
import { pushVerdict, drainVerdicts, markSurfaced, readPendingAck, clearPendingAck } from './verdict-surface-store.mjs';
|
|
|
|
const dir = () => mkdtempSync(join(tmpdir(), 'vsurf-'));
|
|
|
|
describe('verdict-surface-store', () => {
|
|
it('push → drain one-shot (drain чистит)', () => {
|
|
const d = dir();
|
|
pushVerdict('s1', { outcome: 'NO-GO', gate: 'judge' }, d);
|
|
expect(drainVerdicts('s1', d)).toHaveLength(1);
|
|
expect(drainVerdicts('s1', d)).toHaveLength(0);
|
|
});
|
|
it('пер-сессия: чужие не видны', () => {
|
|
const d = dir();
|
|
pushVerdict('s1', { outcome: 'GO' }, d);
|
|
expect(drainVerdicts('s2', d)).toHaveLength(0);
|
|
});
|
|
it('pending-ack: mark → read → clear', () => {
|
|
const d = dir();
|
|
markSurfaced('s1', ['NO-GO'], d);
|
|
expect(readPendingAck('s1', d)).toEqual(['NO-GO']);
|
|
clearPendingAck('s1', d);
|
|
expect(readPendingAck('s1', d)).toBeNull();
|
|
});
|
|
it('fail-quiet: битый baseDir не кидает', () => {
|
|
expect(() => drainVerdicts('s1', '\0bad')).not.toThrow();
|
|
expect(drainVerdicts('s1', '\0bad')).toEqual([]);
|
|
});
|
|
});
|