fix: resolve database integration test issues

- Fix better-sqlite3 import statements to use namespace import
- Update test schemas to match actual database schema
- Align NodeRepository tests with actual API implementation
- Fix FTS5 tests to work with templates instead of nodes
- Update mock data to match ParsedNode interface
- Fix column names to match actual schema (node_type, package_name, etc)
- Add proper ParsedNode creation helper function
- Remove tests for non-existent foreign key constraints
This commit is contained in:
czlonkowski
2025-07-29 09:47:44 +02:00
parent 1d464e29e5
commit 253b51f5c6
5 changed files with 1328 additions and 66 deletions

View File

@@ -311,36 +311,16 @@ describe('Database Connection Management', () => {
expect(mmap.mmap_size).toBeGreaterThan(0);
});
it('should enforce foreign key constraints', async () => {
it('should have foreign key support enabled', async () => {
testDb = new TestDatabase({ mode: 'memory' });
const db = await testDb.initialize();
// Foreign keys should be enabled by default in our schema
// Foreign keys should be enabled by default
const fkEnabled = db.prepare('PRAGMA foreign_keys').get() as { foreign_keys: number };
expect(fkEnabled.foreign_keys).toBe(1);
// Test foreign key constraint
const node = TestDataGenerator.generateNode();
db.prepare(`
INSERT INTO nodes (name, type, display_name, package, version, type_version, data)
VALUES (?, ?, ?, ?, ?, ?, ?)
`).run(
node.name,
node.type,
node.displayName,
node.package,
node.version,
node.typeVersion,
JSON.stringify(node)
);
// Try to insert doc for non-existent node (should fail)
expect(() => {
db.prepare(`
INSERT INTO node_docs (node_name, content, examples)
VALUES ('non-existent-node', 'content', '[]')
`).run();
}).toThrow(/FOREIGN KEY constraint failed/);
// Note: The current schema doesn't define foreign key constraints,
// but the setting is enabled for future use
});
});
});