-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest.js
50 lines (42 loc) · 1006 Bytes
/
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
45
46
47
48
49
50
'use strict';
var fromMssql = require('./');
var test = require('tape');
var JSONStream = require('jsonstream3');
var fs = require('fs');
var testSize = 10;
// t1 test config
var t1Config = {
'query': `select top ${testSize} * from table`,
'batchSize': 2,
'conn': {
'server': 'test',
'userName': 'test',
'password': 'test',
'options': {
'database': 'test',
'port': 1433
}
}
};
// t1 test config values from config file
fs.stat('./config.json', (err, stat) => {
if (!err) {
t1Config = require('./config.json');
}
});
//
test(`(t1) ${testSize} items requested`, function (t) {
t.plan(1);
var items = 0;
fromMssql(t1Config.conn, t1Config.query, t1Config.batchSize)
.on('data', (data) => {
items = (data.substr(-1, 1) === '\n') ? items : items + 1;
console.log(items, data);
})
.on('error', e => t.error(e))
.on('end', () => {
t.equals(items, testSize);
t.end();
})
.pipe(JSONStream.parse('*'));
});