-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathtest_nodefs.js
More file actions
35 lines (30 loc) · 894 Bytes
/
test_nodefs.js
File metadata and controls
35 lines (30 loc) · 894 Bytes
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
exports.test = function(SQL, assert) {
//Node filesystem module - You know that.
var fs = require('fs');
//Ditto, path module
var path = require('path');
SQL.mount('/nfs', __dirname);
//Works
var db = new SQL.Database('/nfs/test.sqlite');
//[{"columns":["id","content"],"values":[["0","hello"],["1","world"]]}]
var res = db.exec("SELECT * FROM test WHERE id = 0");
assert.deepEqual(res,
[{"columns":["id","content"],"values":[[0,"hello"]]}],
"One should be able to read the mounted file from disk");
db.close();
}
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 node file': function(assert){
exports.test(sql, assert);
}
});
})
.catch((e)=>{
console.error(e);
assert.fail(e);
});
}