-
Notifications
You must be signed in to change notification settings - Fork 94
/
base.js
43 lines (38 loc) · 1.27 KB
/
base.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
"use strict";
const Connection = require("../src/connection");
const ConnOptions = require("../src/config/connection-options");
const Conf = require("./conf");
const connOptions = new ConnOptions(Conf.baseConfig);
//*****************************************************************
// initialize share connection
//*****************************************************************
before("share initialization", done => {
if (global.shareConn) {
done();
} else {
console.log("connecting share connection : ");
console.log(connOptions);
console.log(" ");
let conn = new Connection(connOptions);
conn.connect(err => {
if (err) {
done(err);
} else {
done();
}
});
global.shareConn = conn;
}
});
after("share destroy", () => {
if (shareConn && shareConn._connected) {
shareConn.end(() => (global.shareConn = undefined));
}
});
//*****************************************************************
// create test connection with default test options + param
//*****************************************************************
module.exports.createConnection = function createConnection(opts) {
let connOptionTemp = Object.assign({}, Conf.baseConfig, opts);
return new Connection(new ConnOptions(connOptionTemp));
};