-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdbTest.js
70 lines (50 loc) · 1.62 KB
/
dbTest.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
var nakedSlice = require("../lib/api/etc/nakedSlice");
dbUtil = require("../lib/db/dbutil"),
jsonLoader = require('./testUtil'),
trioContext = require('../lib/context/trioContext'),
path = require('path'),
db = require('../lib/db/yaeldb');
var jsonFile;
var jsonStr;
var jsonLen;
jsonLoader = new jsonLoader();
jsonFile = jsonLoader.loadJSONfile("./algo1/trio.json", null);
if (jsonFile !== null || jsonFile !== 'undefined'){
jsonStr = JSON.stringify(jsonFile);
jsonLen = jsonStr.length;
}
console.log("-------------testing-----------------");
var buffStr = "This is a test slice 123";
var sliceStr = jsonLen.toString() + '|' + jsonStr + '|' + buffStr;
console.log("--------------source string ---------------");
console.log(sliceStr);
cObj = dbUtil.stringToJsonNArray(sliceStr);
var testSlice = new nakedSlice(cObj[0].length);
testSlice.buffer = cObj[0];
testSlice.jsonAssmeblyObject = cObj[1];
testSlice.ID = "6.6.6";
var resultString ="";
resultString = dbUtil.sliceToString(testSlice);
console.log("--------result slice string--------");
console.log(resultString);
if (sliceStr === resultString)
console.log("-----------Test Green-----------");
trioContext = new trioContext();
var pathToAlgo = path.resolve('./algo1');
trioContext.startPlugin(pathToAlgo, 1);
var ninja = function(){
db.getASlice(function (slice){
if ((slice !== null) && (slice.ID !== "1.0.100")){
console.log("ninja slice.id " + slice.ID);
db.giveResult(slice);
setTimeout(ninja,0);
}else{
console.log("yep I'm done");
}
});
};
setTimeout(ninja,0);
process.on('exit', function (code, signal){
console.log('what?');
db.flushDB();
});