feat: add topic alias resolution APIs
This commit is contained in:
@@ -16,7 +16,7 @@ afterEach(async () => {
|
||||
});
|
||||
|
||||
describe('initializeSchema', () => {
|
||||
it('creates the topics, facts, fact_topics, and topic_relations tables', async () => {
|
||||
it('creates the topics, facts, fact_topics, topic_relations, and topic_aliases tables', async () => {
|
||||
const connection = await createDatabase({ client: 'sqlite', filename: ':memory:' });
|
||||
openConnections.push(connection.destroy);
|
||||
|
||||
@@ -35,6 +35,7 @@ describe('initializeSchema', () => {
|
||||
expect(tableNames).toContain('facts');
|
||||
expect(tableNames).toContain('fact_topics');
|
||||
expect(tableNames).toContain('topic_relations');
|
||||
expect(tableNames).toContain('topic_aliases');
|
||||
});
|
||||
|
||||
it('creates the expected columns for each table', async () => {
|
||||
@@ -47,6 +48,7 @@ describe('initializeSchema', () => {
|
||||
const factsColumns = await sql<{ name: string }>`PRAGMA table_info(facts)`.execute(connection.db);
|
||||
const factTopicsColumns = await sql<{ name: string }>`PRAGMA table_info(fact_topics)`.execute(connection.db);
|
||||
const topicRelationsColumns = await sql<{ name: string }>`PRAGMA table_info(topic_relations)`.execute(connection.db);
|
||||
const topicAliasesColumns = await sql<{ name: string }>`PRAGMA table_info(topic_aliases)`.execute(connection.db);
|
||||
|
||||
expect(topicsColumns.rows.map((row) => row.name)).toEqual([
|
||||
'id',
|
||||
@@ -85,6 +87,16 @@ describe('initializeSchema', () => {
|
||||
'relation',
|
||||
'created_at',
|
||||
]);
|
||||
|
||||
expect(topicAliasesColumns.rows.map((row) => row.name)).toEqual([
|
||||
'id',
|
||||
'topic_id',
|
||||
'alias',
|
||||
'normalized_alias',
|
||||
'is_primary',
|
||||
'created_at',
|
||||
'updated_at',
|
||||
]);
|
||||
});
|
||||
|
||||
it('is idempotent when called more than once', async () => {
|
||||
|
||||
Reference in New Issue
Block a user