Skip to content

sqlite3 does not work with sinon #359

Open
@rogierschouten

Description

@rogierschouten

Hi,

This is the first npm package I've seen that stops working when you use the sinon test framework. This framework is used to fake time during tests.

For instance, the following example hangs when performing its query. If you strip out all sinon-related code then everything works. Any clues as to what causes this? It would greatly help in testing if we could use an in-memory database.

var sinon = require("sinon");
var sqlite3 = require("sqlite3");

var clock = sinon.useFakeTimers();
var done = false;

var db = new sqlite3.Database(':memory:', sqlite3.OPEN_READWRITE | sqlite3.OPEN_CREATE);
db.serialize();

db.each("SELECT 1", [], onRow, function (err, count) {
    console.log("query done", err, count);
    done = true;
});

function onRow (err, row) {
    console.log("row", err, row);
}

while (!done) {
    clock.tick(5000);
}
clock.restore();

Rogier

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions