feat(schema): 004 — agents, agent_tokens, conversations, messages
This commit is contained in:
24
tests/db/migration_004.test.js
Normal file
24
tests/db/migration_004.test.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import { describe, it, expect, beforeEach } from 'vitest';
|
||||
import { resetDb, withClient } from '../helpers/db.js';
|
||||
import { migrateUp } from '../../lib/db/migrate.js';
|
||||
|
||||
describe('migration 004 — agents', () => {
|
||||
beforeEach(async () => { await resetDb(); await migrateUp(); });
|
||||
|
||||
it('creates agents, agent_tokens, conversations, messages', async () => {
|
||||
await withClient(async (c) => {
|
||||
for (const t of ['agents','agent_tokens','conversations','messages']) {
|
||||
const { rows } = await c.query(`SELECT to_regclass('public.' || $1) AS t;`, [t]);
|
||||
expect(rows[0].t).toBe(t);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('agents.kind enum is enforced', async () => {
|
||||
await withClient(async (c) => {
|
||||
await expect(c.query(
|
||||
`INSERT INTO agents(slug, name, kind) VALUES('x','X','invalid');`
|
||||
)).rejects.toThrow(/check/i);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user