-
Notifications
You must be signed in to change notification settings - Fork 94
/
base.js
37 lines (32 loc) · 1.11 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
"use strict";
const Connection = require("../lib/connection");
const ConnOptions = require("../lib/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 {
let conn = new Connection(connOptions);
conn
.connect()
.then(done)
.catch(done);
global.shareConn = conn;
}
});
after("share destroy", () => {
if (shareConn) {
shareConn.end().then(() => (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));
};