fix: guard-projection tests — db sharing + async assertions + event format
CI / test (push) Has been cancelled
CI / test (push) Has been cancelled
This commit is contained in:
@@ -6,10 +6,11 @@ import {
|
||||
clearGuardExpressionCache,
|
||||
getGuardState,
|
||||
GuardViolationError,
|
||||
initGuardSchema,
|
||||
matchEventKindPattern,
|
||||
registerGuard,
|
||||
} from './guard-projection.js';
|
||||
import { createScopedStore } from './store.js';
|
||||
} from './guard-projection.ts';
|
||||
import { createScopedStore } from './store.ts';
|
||||
|
||||
function mkScoped() {
|
||||
const root = mkdtempSync(join(tmpdir(), 'pulse-guard-'));
|
||||
@@ -17,7 +18,10 @@ function mkScoped() {
|
||||
basePath: join(root, 'scopes'),
|
||||
objectsDir: join(root, 'objects'),
|
||||
});
|
||||
return { root, scoped, db: scoped.scopeDatabase('g'), store: scoped.scope('g') };
|
||||
const store = scoped.scope('g');
|
||||
const db = scoped.scopeDatabase('g');
|
||||
initGuardSchema(db);
|
||||
return { root, scoped, db, store };
|
||||
}
|
||||
|
||||
let last: ReturnType<typeof mkScoped> | null = null;
|
||||
@@ -82,13 +86,13 @@ test('illegal event rejected when task already open', async () => {
|
||||
occurredAt: 1,
|
||||
});
|
||||
|
||||
expect(async () => {
|
||||
await store.appendEvent({
|
||||
await expect(
|
||||
store.appendEvent({
|
||||
kind: 'task.created',
|
||||
key: 't1',
|
||||
occurredAt: 2,
|
||||
});
|
||||
}).toThrow(GuardViolationError);
|
||||
}),
|
||||
).rejects.toThrow(GuardViolationError);
|
||||
});
|
||||
|
||||
test('state transitions created → claimed → completed', async () => {
|
||||
|
||||
Reference in New Issue
Block a user