Skip to content

Commit c5fd169

Browse files
committed
Add (failing) test ensuring commit_hook does not overwrite update_hook
1 parent 16c074c commit c5fd169

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/callbacks.test.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,5 +550,31 @@ for (const [key, factory] of FACTORIES) {
550550
expect(rc).toEqual(SQLite.SQLITE_OK);
551551
expect(hasRow).toBeFalse();
552552
});
553+
554+
it('does not overwrite update_hook', async function() {
555+
let rc;
556+
rc = await sqlite3.exec(db, `
557+
CREATE TABLE t(i integer primary key, x);
558+
`);
559+
expect(rc).toEqual(SQLite.SQLITE_OK);
560+
561+
let updateHookInvocationsCount = 0;
562+
sqlite3.update_hook(db, (...args) => {
563+
updateHookInvocationsCount++;
564+
});
565+
566+
let commitHookInvocationsCount = 0;
567+
sqlite3.commit_hook(db, () => {
568+
commitHookInvocationsCount++;
569+
});
570+
571+
rc = await sqlite3.exec(db, `
572+
INSERT INTO t VALUES (1, 'foo');
573+
`);
574+
expect(rc).toEqual(SQLite.SQLITE_OK);
575+
576+
expect(updateHookInvocationsCount).toEqual(1);
577+
expect(commitHookInvocationsCount).toEqual(1);
578+
});
553579
});
554580
}

0 commit comments

Comments
 (0)