-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathtest_fts5.js
More file actions
28 lines (24 loc) · 799 Bytes
/
test_fts5.js
File metadata and controls
28 lines (24 loc) · 799 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
exports.test = function(sql, assert){
// Create a database
var db = new sql.Database();
// Create table, insert data
db.exec("CREATE VIRTUAL TABLE Test_Fts5 USING fts5(text);");
db.exec("INSERT INTO Test_Fts5 VALUES ('welcome home'), ('wonderful'), ('thanks for all the fish');");
var res = db.exec("SELECT * FROM Test_Fts5 WHERE Test_Fts5 MATCH 'welcome';");
assert.deepEqual(res[0].values, [["welcome home"]], "full text search results");
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 errors': function(assert){
exports.test(sql, assert);
}
});
})
.catch((e)=>{
console.error(e);
});
}