-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathtest_issue55.js
37 lines (29 loc) · 1.15 KB
/
test_issue55.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
exports.test = function(SQL, assert) {
var fs = require('fs');
var path = require('path');
var filebuffer = fs.readFileSync(path.join(__dirname, 'issue55.db'));
//Works
var db = new SQL.Database(filebuffer);
var origCount = db.prepare("SELECT COUNT(*) AS count FROM networklocation").getAsObject({}).count;
db.run("INSERT INTO networklocation (x, y, network_id, floor_id) VALUES (?, ?, ?, ?)", [123, 123, 1, 1]);
var count = db.prepare("SELECT COUNT(*) AS count FROM networklocation").getAsObject({}).count;
assert.equal(count, origCount + 1, "The row has been inserted");
var dbCopy = new SQL.Database(db.export());
var newCount = dbCopy.prepare("SELECT COUNT(*) AS count FROM networklocation").getAsObject({}).count;
assert.equal(newCount, count, "export and reimport copies all the data");
};
if (module == require.main) {
const target_file = process.argv[2];
const sql_loader = require('./load_sql_lib');
sql_loader(target_file).then((sql)=>{
require('test').run({
'test issue 55': function(assert){
exports.test(sql, assert);
}
});
})
.catch((e)=>{
console.error(e);
assert.fail(e);
});
}