-
-
Notifications
You must be signed in to change notification settings - Fork 829
/
Copy pathaffected.test.js
32 lines (29 loc) · 1007 Bytes
/
affected.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
var sqlite3 = require('..');
var assert = require('assert');
describe('query properties', function() {
var db;
before(function(done) {
db = new sqlite3.Database(':memory:');
db.run("CREATE TABLE foo (id INT, txt TEXT)", done);
});
it('should return the correct lastID', function(done) {
var stmt = db.prepare("INSERT INTO foo VALUES(?, ?)");
var j = 1;
for (var i = 0; i < 5000; i++) {
stmt.run(i, "demo", function(err) {
if (err) throw err;
// Relies on SQLite's row numbering to be gapless and starting
// from 1.
assert.equal(j++, this.lastID);
});
}
db.wait(done);
});
it('should return the correct changes count', function(done) {
db.run("UPDATE foo SET id = id + 1 WHERE id % 2 = 0", function(err) {
if (err) throw err;
assert.equal(2500, this.changes);
done();
});
});
});