fix: update community integration test mock for INSERT OR REPLACE

The mock SQL matching used 'INSERT INTO nodes' which doesn't match
'INSERT OR REPLACE INTO nodes'. Also added handler for the new
SELECT npm_readme query in saveNode.

Conceived by Romuald Członkowski - https://www.aiadvisors.pl/en

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
czlonkowski
2026-03-26 15:40:52 +01:00
parent af2cfec668
commit 8e49013d72

View File

@@ -87,7 +87,7 @@ class InMemoryDatabaseAdapter implements DatabaseAdapter {
class InMemoryPreparedStatement implements PreparedStatement {
run = vi.fn((...params: any[]): RunResult => {
if (this.sql.includes('INSERT INTO nodes')) {
if (this.sql.includes('INSERT') && this.sql.includes('INTO nodes')) {
const node = this.paramsToNode(params);
this.adapter.saveNode(node);
return { changes: 1, lastInsertRowid: 1 };
@@ -100,6 +100,9 @@ class InMemoryPreparedStatement implements PreparedStatement {
});
get = vi.fn((...params: any[]) => {
if (this.sql.includes('SELECT npm_readme')) {
return undefined; // No existing docs to preserve
}
if (this.sql.includes('SELECT * FROM nodes WHERE node_type = ?')) {
return this.adapter.getNode(params[0]);
}