itoolkit 1.0.1 → 1.1.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/README.md +6 -2
  2. package/lib/CommandCall.js +2 -16
  3. package/lib/Connection.js +2 -16
  4. package/lib/Deprecated.js +892 -895
  5. package/lib/ProgramCall.js +2 -16
  6. package/lib/itoolkit.js +2 -16
  7. package/lib/transports/httpTransport.js +2 -16
  8. package/lib/transports/idbTransport.js +2 -16
  9. package/lib/transports/odbcTransport.js +2 -16
  10. package/lib/transports/sshTransport.js +2 -16
  11. package/package.json +21 -10
  12. package/.eslintrc.js +0 -39
  13. package/.gitattributes +0 -2
  14. package/.readthedocs.yml +0 -16
  15. package/CHANGELOG.md +0 -228
  16. package/contributors.txt +0 -2
  17. package/test/README.md +0 -44
  18. package/test/functional/CommandCallFunctional.js +0 -87
  19. package/test/functional/ProgramCallFunctional.js +0 -106
  20. package/test/functional/checkObjectExists.js +0 -193
  21. package/test/functional/checkVersion.js +0 -17
  22. package/test/functional/config.js +0 -35
  23. package/test/functional/deprecated/commandsFunctional.js +0 -108
  24. package/test/functional/deprecated/iDataQueueFunctional.js +0 -103
  25. package/test/functional/deprecated/iNetworkFunctional.js +0 -159
  26. package/test/functional/deprecated/iObjFunctional.js +0 -349
  27. package/test/functional/deprecated/iPgmFunctional.js +0 -104
  28. package/test/functional/deprecated/iProdFunctional.js +0 -160
  29. package/test/functional/deprecated/iSqlFunctional.js +0 -453
  30. package/test/functional/deprecated/iUserSpaceFunctional.js +0 -138
  31. package/test/functional/deprecated/iWorkFunctional.js +0 -238
  32. package/test/functional/iDataQueueFunctional.js +0 -83
  33. package/test/functional/iNetworkFunctional.js +0 -131
  34. package/test/functional/iObjFunctional.js +0 -326
  35. package/test/functional/iProdFunctional.js +0 -134
  36. package/test/functional/iSqlFunctional.js +0 -448
  37. package/test/functional/iUserSpaceFunctional.js +0 -134
  38. package/test/functional/iWorkFunctional.js +0 -215
  39. package/test/unit/CommandCallUnit.js +0 -87
  40. package/test/unit/ConnectionUnit.js +0 -188
  41. package/test/unit/ProgamCallUnit.js +0 -281
  42. package/test/unit/deprecated/commandsUnit.js +0 -87
  43. package/test/unit/deprecated/iConnUnit.js +0 -158
  44. package/test/unit/deprecated/iPgmUnit.js +0 -211
  45. package/test/unit/deprecated/iSqlUnit.js +0 -441
  46. package/test/unit/deprecated/xmlToJsonUnit.js +0 -200
@@ -1,106 +0,0 @@
1
- // Copyright (c) International Business Machines Corp. 2019
2
-
3
- // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
4
- // associated documentation files (the "Software"), to deal in the Software without restriction,
5
- // including without limitation the rights to use, copy, modify, merge, publish, distribute,
6
- // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
7
- // furnished to do so, subject to the following conditions:
8
-
9
- // The above copyright notice and this permission notice shall be included in all copies or
10
- // substantial portions of the Software.
11
-
12
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
13
- // NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
14
- // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
15
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17
-
18
- const { expect } = require('chai');
19
- const { parseString } = require('xml2js');
20
- const { ProgramCall, Connection } = require('../../lib/itoolkit');
21
- const { config, printConfig } = require('./config');
22
-
23
- describe('ProgramCall Functional Tests', function () {
24
- before(function () {
25
- printConfig();
26
- });
27
-
28
- describe('addParam', function () {
29
- it('calls QWCRSVAL program checks if it ran successfully', function (done) {
30
- const connection = new Connection(config);
31
-
32
- const program = new ProgramCall('QWCRSVAL', { lib: 'QSYS' });
33
-
34
- const outBuf = {
35
- type: 'ds',
36
- io: 'out',
37
- fields: [
38
- { type: '10i0', value: 0 },
39
- { type: '10i0', value: 0 },
40
- { type: '36h', value: '' },
41
- { type: '10A', value: '' },
42
- { type: '1A', value: '' },
43
- { type: '1A', value: '' },
44
- { type: '10i0', value: 0 },
45
- { type: '10i0', value: 0 },
46
- ],
47
- };
48
-
49
- const errno = {
50
- type: 'ds',
51
- io: 'both',
52
- len: 'rec2',
53
- fields: [
54
- {
55
- name: 'bytes_provided',
56
- type: '10i0',
57
- value: 0,
58
- setlen: 'rec2',
59
- },
60
- { name: 'bytes_available', type: '10i0', value: 0 },
61
- { name: 'msgid', type: '7A', value: '' },
62
- { type: '1A', value: '' },
63
- ],
64
- };
65
-
66
- program.addParam(outBuf);
67
- program.addParam({ type: '10i0', value: 66 });
68
- program.addParam({ type: '10i0', value: 1 });
69
- program.addParam({ type: '10A', value: 'QCCSID' });
70
- program.addParam(errno);
71
- connection.add(program);
72
- connection.run((error, xmlOut) => {
73
- expect(error).to.equal(null);
74
- parseString(xmlOut, (parseError, result) => {
75
- expect(parseError).to.equal(null);
76
- expect(result.myscript.pgm[0].success[0]).to.include('+++ success QSYS QWCRSVAL');
77
- done();
78
- });
79
- });
80
- });
81
- });
82
-
83
- describe.skip('addReturn', function () {
84
- // ZZSRV6 program requires XMLSERVICE built with tests
85
- // Skip for now, we need to add before hook to check ZZSRV6 is available
86
- it.skip('calls ZZVARY4 and checks the return value', function (done) {
87
- const connection = new Connection(config);
88
-
89
- const program = new ProgramCall('ZZSRV6', { lib: 'XMLSERVICE', func: 'ZZVARY4' });
90
-
91
- program.addParam({ type: '10A', varying: '4', value: 'Gill' });
92
- const testValue = 'NEW_NAME';
93
- program.addReturn('0', '20A', { varying: '4', name: testValue });
94
- connection.add(program);
95
- connection.run((error, xmlOut) => {
96
- expect(error).to.equal(null);
97
- parseString(xmlOut, (parseError, result) => {
98
- expect(parseError).to.equal(null);
99
- expect(result.myscript.pgm[0].success[0]).to.include('+++ success');
100
- expect(result.myscript.pgm[0].return[0].data[0]._).to.equal('my name is Gill');
101
- done();
102
- });
103
- });
104
- });
105
- });
106
- });
@@ -1,193 +0,0 @@
1
- /* eslint-disable default-param-last */
2
-
3
- const lib = 'NODETKTEST';
4
- const createLib = `CRTLIB LIB(${lib}) TYPE(*TEST) TEXT('Used to test Node.js toolkit')`;
5
- const findLib = `SELECT SCHEMA_NAME FROM qsys2.sysschemas WHERE SCHEMA_NAME = '${lib}'`;
6
-
7
- function checkObjectExistsSSH(config, object = {}, callback) {
8
- // ssh2 is an optional dependency, since users may not use this transport
9
- // thus we can't globally require it
10
- // eslint-disable-next-line global-require, import/no-extraneous-dependencies
11
- const { Client } = require('ssh2');
12
-
13
- const client = new Client();
14
- const checkLibCommand = `system 'CHKOBJ OBJ(QSYS/${lib}) OBJTYPE(*LIB)'`;
15
- const checkObjectCommand = `system 'CHKOBJ OBJ(${lib}/${object.name}) OBJTYPE(${object.type})'`;
16
-
17
- // if client.connect has an error it will be handled here
18
- client.on('error', (error) => {
19
- callback(error, false);
20
- });
21
-
22
- client.on('ready', () => {
23
- client.exec(checkLibCommand, (checkLibError, checkLibStream) => {
24
- /* eslint-disable no-console */
25
- console.log(`executing ${checkLibCommand}`);
26
- if (checkLibError) {
27
- callback(checkLibError, false);
28
- return;
29
- }
30
- checkLibStream.stderr.on('data', (data) => {
31
- console.log(`STDERR: ${data}`);
32
- });
33
- checkLibStream.on('exit', (checkLibCode) => {
34
- if (checkLibCode !== 0) {
35
- if (config.verbose) { console.log(`Command exited abnormally with code: ${checkLibCode}`); }
36
- const libError = new Error(`${lib} lib was not found!\nCreate it by running: ${createLib}`);
37
- client.end();
38
- client.destroy();
39
- callback(libError, false);
40
- return;
41
- }
42
- client.exec(checkObjectCommand, (checkObjectError, checkObjectStream) => {
43
- if (config.verbose) { console.log(`executing ${checkObjectCommand}`); }
44
- if (checkObjectError) {
45
- client.end();
46
- client.destroy();
47
- callback(checkLibError, false);
48
- return;
49
- }
50
- checkObjectStream.stderr.on('data', (data) => {
51
- console.log(`STDERR: ${data}`);
52
- });
53
- checkObjectStream.on('exit', (checkObjectCode) => {
54
- if (checkObjectCode !== 0) {
55
- client.end();
56
- client.destroy();
57
- console.log(`Command exited abnormally with code: ${checkObjectCode}`);
58
- const objectError = new Error(`${object.name} was not found!\nCreate it by running: ${object.createObject}`);
59
- callback(objectError);
60
- return;
61
- }
62
- client.end();
63
- client.destroy();
64
- callback(null, true);
65
- });
66
- });
67
- });
68
- });
69
- });
70
-
71
- client.connect(config);
72
- }
73
-
74
- function checkObjectExistsODBC(config, object = {}, callback) {
75
- // odbc is an optional dependency, since users may not use this transport
76
- // thus we can't globally require it
77
- // eslint-disable-next-line global-require, import/no-extraneous-dependencies
78
- const odbc = require('odbc');
79
-
80
- const connectionString = config.dsn || `DRIVER=IBM i Access ODBC Driver;SYSTEM=${config.host};UID=${config.username};PWD=${config.password};`;
81
-
82
- odbc.connect(connectionString, (connectError, connection) => {
83
- if (connectError) {
84
- callback(connectError, false);
85
- return;
86
- }
87
- connection.query(findLib, (findLibError, libResult) => {
88
- if (findLibError) {
89
- callback(findLibError, false);
90
- return;
91
- }
92
- if (config.verbose) {
93
- console.log('find lib result set: ', libResult);
94
- }
95
- if (!libResult.length) {
96
- const libError = new Error(`${lib} lib was not found!\nCreate it by running:${createLib}`);
97
- callback(libError, false);
98
- return;
99
- }
100
- connection.query(object.findObject, (findObjectError, result) => {
101
- if (findObjectError) {
102
- callback(findObjectError, false);
103
- return;
104
- }
105
- if (config.verbose) {
106
- console.log('find lib result set: ', result);
107
- }
108
- if (!result.length) {
109
- const resultError = new Error(`${object.name} was not found! Create it by running: ${object.createObject}`);
110
- callback(resultError, false);
111
- return;
112
- }
113
- callback(null, true);
114
- });
115
- });
116
- });
117
- }
118
-
119
- function checkObjectExistsIDB(config, object = {}, callback) {
120
- // idb-connector is an optional dependency, since users may not use this transport
121
- // thus we can't globally require it
122
- // eslint-disable-next-line max-len
123
- // eslint-disable-next-line global-require, import/no-extraneous-dependencies, import/no-unresolved
124
- const { dbconn, dbstmt } = require('idb-connector');
125
-
126
- /* eslint-disable new-cap */
127
- const connection = new dbconn();
128
- connection.conn('*LOCAL');
129
- const statement = new dbstmt(connection);
130
-
131
- statement.exec(findLib, (libResult, error) => {
132
- if (error) {
133
- callback(error, null);
134
- return;
135
- }
136
- if (config.verbose) {
137
- console.log('find lib result set: ', libResult);
138
- }
139
- if (!libResult.length) {
140
- const libError = new Error(`${lib} lib was not found! Create it by running: ${createLib}`);
141
- callback(libError, null);
142
- return;
143
- }
144
- statement.closeCursor();
145
- statement.exec(object.findObject, (result, findObjecError) => {
146
- if (findObjecError) {
147
- callback(findObjecError, null);
148
- return;
149
- }
150
- if (config.verbose) {
151
- console.log('find object result set: ', result);
152
- }
153
- if (!result.length) {
154
- const resultError = new Error(`${object.name} was not found! Create it by running: ${object.createObject}`);
155
- callback(resultError, null);
156
- return;
157
- }
158
- statement.close();
159
- connection.disconn();
160
- connection.close();
161
- callback(null, true);
162
- });
163
- });
164
- }
165
-
166
- function checkObjectExists(config, name, type, callback) {
167
- const object = { type };
168
-
169
- if (type === '*DTAARA') {
170
- object.name = name;
171
- object.createObject = `CRTDTAARA DTAARA(${lib}/${name}) TYPE(*CHAR) TEXT('TEST DATA AREA FOR NODE TOOLKIT') VALUE('Hello From Test Data Area!')`;
172
- } else if (type === '*DTAQ') {
173
- object.name = name;
174
- object.createObject = `CRTDTAQ DTAQ(${lib}/${name}) MAXLEN(100) AUT(*EXCLUDE) TEXT('TEST DQ FOR NODE TOOLKIT TESTS')`;
175
- }
176
-
177
- object.findObject = `SELECT OBJNAME FROM TABLE (QSYS2.OBJECT_STATISTICS('${lib}', '${type}')) AS X WHERE OBJNAME = '${name}'`;
178
- // eslint-disable-next-line no-param-reassign
179
- config.transportOptions.verbose = config.verbose;
180
-
181
- if (config.transport === 'idb') {
182
- checkObjectExistsIDB(config.transportOptions, object, callback);
183
- } else if (config.transport === 'odbc') {
184
- checkObjectExistsODBC(config.transportOptions, object, callback);
185
- } else if (config.transport === 'ssh') {
186
- checkObjectExistsSSH(config.transportOptions, object, callback);
187
- } else {
188
- // we cannot check object existence using the rest transport
189
- callback(null, true);
190
- }
191
- }
192
-
193
- module.exports.checkObjectExists = checkObjectExists;
@@ -1,17 +0,0 @@
1
- /**
2
- * Checks if XMLSERVICE version supports QSH.
3
- * XMLSERVICE >= 1.9.8 supports QSH
4
- * @param {string} version - expects sematic version i.e. 1.2.3
5
- */
6
- function isQSHSupported(version) {
7
- // maps array of strings to numbers i.e. ['1', '2', '3'] -> [1, 2, 3]
8
- const semver = version.split('.').map(Number);
9
- if (semver[0] === 1 && semver[1] < 9) {
10
- return false;
11
- } if (semver[0] === 1 && semver[1] === 9 && semver[2] < 8) {
12
- return false;
13
- }
14
- return true;
15
- }
16
-
17
- module.exports.isQSHSupported = isQSHSupported;
@@ -1,35 +0,0 @@
1
- const { readFileSync } = require('fs');
2
-
3
- let privateKey;
4
- if (process.env.TKPK) {
5
- privateKey = readFileSync(process.env.TKPK, 'utf-8');
6
- }
7
-
8
- const config = {
9
- transport: process.env.TKTRANSPORT || 'ssh',
10
- verbose: !!process.env.TKVERBOSE,
11
- transportOptions: {
12
- database: process.env.TKDB || '*LOCAL',
13
- username: process.env.TKUSER || '',
14
- password: process.env.TKPASS || '',
15
- host: process.env.TKHOST || 'localhost',
16
- port: process.env.TKPORT,
17
- path: process.env.TKPATH || '/cgi-bin/xmlcgi.pgm',
18
- url: process.env.TKURL,
19
- privateKey,
20
- // passphrase is used by the ssh transport to decrypt the private key
21
- passphrase: process.env.TKPHRASE,
22
- dsn: process.env.TKDSN,
23
- },
24
- };
25
-
26
- function printConfig() {
27
- /* eslint-disable no-console */
28
- console.log('-----------------------');
29
- console.log('transport:', config.transport);
30
- console.log(`verbose: ${config.verbose ? 'on' : 'off'}`);
31
- console.log('-----------------------');
32
- }
33
-
34
- module.exports.config = config;
35
- module.exports.printConfig = printConfig;
@@ -1,108 +0,0 @@
1
- // Copyright (c) International Business Machines Corp. 2019
2
-
3
- // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
4
- // associated documentation files (the "Software"), to deal in the Software without restriction,
5
- // including without limitation the rights to use, copy, modify, merge, publish, distribute,
6
- // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
7
- // furnished to do so, subject to the following conditions:
8
-
9
- // The above copyright notice and this permission notice shall be included in all copies or
10
- // substantial portions of the Software.
11
-
12
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
13
- // NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
14
- // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
15
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17
-
18
- /* eslint-disable new-cap */
19
-
20
- const { expect } = require('chai');
21
- const { parseString } = require('xml2js');
22
- const {
23
- iCmd, iSh, iQsh, iConn, iPgm,
24
- } = require('../../../lib/itoolkit');
25
-
26
- const { config, printConfig } = require('../config');
27
- const { isQSHSupported } = require('../checkVersion');
28
-
29
- // deprecated tests are in place to test compatability using deprecated classes and functions
30
- // these tests use deprecated iConn Class to create a connnection
31
- // iConn only supported idb and rest transports
32
- if (config.transport !== 'idb' && config.transport !== 'rest') {
33
- throw new Error('Only idb and rest transports are available for deprecated tests');
34
- }
35
- const {
36
- database, username, password, host, port = 80, path,
37
- } = config.transportOptions;
38
-
39
- let restOptions = null;
40
- if (config.transport === 'rest') {
41
- restOptions = {
42
- host,
43
- port,
44
- path,
45
- };
46
- }
47
-
48
- describe('iSh, iCmd, iQsh, Functional Tests', function () {
49
- before(function () {
50
- printConfig();
51
- });
52
-
53
- describe('iCmd()', function () {
54
- it('calls CL command', function (done) {
55
- const connection = new iConn(database, username, password, restOptions);
56
- connection.add(iCmd('RTVJOBA USRLIBL(?) SYSLIBL(?)'));
57
- connection.run((xmlOut) => {
58
- parseString(xmlOut, (parseError, result) => {
59
- expect(parseError).to.equal(null);
60
- expect(result.myscript.cmd[0].success[0]).to.include('+++ success RTVJOBA USRLIBL(?) SYSLIBL(?)');
61
- done();
62
- });
63
- });
64
- });
65
- });
66
-
67
- describe('iSh()', function () {
68
- it('calls PASE shell command', function (done) {
69
- const connection = new iConn(database, username, password, restOptions);
70
- connection.add(iSh('system -i wrksyssts'));
71
- connection.run((xmlOut) => {
72
- // xs does not return success property for sh or qsh command calls
73
- // but on error sh or qsh node will not have any inner data
74
- parseString(xmlOut, (parseError, result) => {
75
- expect(parseError).to.equal(null);
76
- expect(result.myscript.sh[0]._).to.match(/(System\sStatus\sInformation)/);
77
- done();
78
- });
79
- });
80
- });
81
- });
82
-
83
- describe('iQsh()', function () {
84
- it('calls QSH command', function (done) {
85
- const connection = new iConn(database, username, password, restOptions);
86
- connection.add(new iPgm('MYPGMTOOLONG'));
87
- connection.add(iQsh('system wrksyssts'));
88
- connection.run((xmlOut) => {
89
- // xs does not return success property for sh or qsh command calls
90
- // but on error sh or qsh node will not have any inner data
91
- parseString(xmlOut, (parseError, result) => {
92
- expect(parseError).to.equal(null);
93
- const match = result.myscript.pgm[0].version[0].match(/\d\.\d\.\d/);
94
- if (!match) {
95
- throw Error('Unable to determine XMLSERVICE version');
96
- }
97
- if (!isQSHSupported(match[0])) {
98
- // skip if QSH is unsupported
99
- console.log(`XMLSERVICE version ${match[0]} does not support QSH`);
100
- this.skip();
101
- }
102
- expect(result.myscript.qsh[0]._).to.match(/(System\sStatus\sInformation)/);
103
- done();
104
- });
105
- });
106
- });
107
- });
108
- });
@@ -1,103 +0,0 @@
1
- // Copyright (c) International Business Machines Corp. 2019
2
-
3
- // Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
4
- // associated documentation files (the "Software"), to deal in the Software without restriction,
5
- // including without limitation the rights to use, copy, modify, merge, publish, distribute,
6
- // sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
7
- // furnished to do so, subject to the following conditions:
8
-
9
- // The above copyright notice and this permission notice shall be included in all copies or
10
- // substantial portions of the Software.
11
-
12
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
13
- // NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
14
- // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
15
- // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
17
-
18
- /* eslint-disable new-cap */
19
-
20
- const { expect } = require('chai');
21
- const { iConn, iDataQueue } = require('../../../lib/itoolkit');
22
- const { config, printConfig } = require('../config');
23
- const { checkObjectExists } = require('../checkObjectExists');
24
-
25
- // deprecated tests are in place to test compatability using deprecated classes and functions
26
- // these tests use deprecated iConn Class to create a connnection.
27
- // iConn only supported idb and rest transports
28
- if (config.transport !== 'idb' && config.transport !== 'rest') {
29
- throw new Error('Only idb and rest transports are available for deprecated tests');
30
- }
31
-
32
- const {
33
- database, username, password, host, port = 80, path,
34
- } = config.transportOptions;
35
-
36
- let restOptions = null;
37
- if (config.transport === 'rest') {
38
- restOptions = {
39
- host,
40
- port,
41
- path,
42
- };
43
- }
44
-
45
- const lib = 'NODETKTEST'; const dqName = 'TESTQ';
46
-
47
- describe('iDataQueue Functional Tests', function () {
48
- before('check if data queue exists for tests', function (done) {
49
- printConfig();
50
- checkObjectExists(config, dqName, '*DTAQ', (error) => {
51
- if (error) { throw error; }
52
- done();
53
- });
54
- });
55
-
56
- describe('constructor', function () {
57
- it('creates and returns an instance of iDataQueue', function () {
58
- const connection = new iConn(database, config.user, password);
59
-
60
- const dq = new iDataQueue(connection);
61
- expect(dq).to.be.instanceOf(iDataQueue);
62
- });
63
- });
64
-
65
- describe('sendToDataQueue', function () {
66
- it('sends data to specified DQ', function (done) {
67
- const connection = new iConn(database, username, password, restOptions);
68
-
69
- const dq = new iDataQueue(connection);
70
-
71
- dq.sendToDataQueue(dqName, lib, 'Hello from DQ!', (output) => {
72
- expect(output).to.equal(true);
73
- done();
74
- });
75
- });
76
- });
77
-
78
- describe('receiveFromDataQueue', function () {
79
- it('receives data from specfied DQ', function (done) {
80
- const connection = new iConn(database, username, password, restOptions);
81
-
82
- const dq = new iDataQueue(connection);
83
-
84
- dq.receiveFromDataQueue(dqName, lib, 100, (output) => {
85
- expect(output).to.be.a('string').and.to.equal('Hello from DQ!');
86
- done();
87
- });
88
- });
89
- });
90
-
91
- describe('clearDataQueue', function () {
92
- it('clears the specifed DQ', function (done) {
93
- const connection = new iConn(database, username, password, restOptions);
94
-
95
- const dq = new iDataQueue(connection);
96
-
97
- dq.clearDataQueue(dqName, lib, (output) => {
98
- expect(output).to.equal(true);
99
- done();
100
- });
101
- });
102
- });
103
- });