forked from journeyapps/node-sqlcipher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathparallel_insert.test.js
44 lines (36 loc) · 1.2 KB
/
parallel_insert.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
33
34
35
36
37
38
39
40
41
42
43
44
var sqlite3 = require('..');
var assert = require('assert');
var helper = require('./support/helper');
describe('parallel', function() {
var db;
before(function(done) {
helper.deleteFile('test/tmp/test_parallel_inserts.db');
helper.ensureExists('test/tmp');
db = new sqlite3.Database('test/tmp/test_parallel_inserts.db', done);
});
var columns = [];
for (var i = 0; i < 128; i++) {
columns.push('id' + i);
}
it('should create the table', function(done) {
db.run("CREATE TABLE foo (" + columns + ")", done);
});
it('should insert in parallel', function(done) {
for (var i = 0; i < 1000; i++) {
for (var values = [], j = 0; j < columns.length; j++) {
values.push(i * j);
}
db.run("INSERT INTO foo VALUES (" + values + ")");
}
db.wait(done);
});
it('should close the database', function(done) {
db.close(done);
});
it('should verify that the database exists', function() {
assert.fileExists('test/tmp/test_parallel_inserts.db');
});
after(function() {
helper.deleteFile('test/tmp/test_parallel_inserts.db');
});
});