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,281 +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 { ProgramCall } = require('../../lib/itoolkit');
20
-
21
- const outBuf = [
22
- { type: '10i0', value: 0 },
23
- { type: '10i0', value: 0 },
24
- { type: '36h', value: '' },
25
- { type: '10A', value: '' },
26
- { type: '1A', value: '' },
27
- { type: '1A', value: '' },
28
- { type: '10i0', value: 0 },
29
- { type: '10i0', value: 0 },
30
- ];
31
- const errno = [
32
- { type: '10i0', value: 0 },
33
- { type: '10i0', value: 0, setlen: 'rec2' },
34
- { type: '7A', value: '' },
35
- { type: '1A', value: '' },
36
- ];
37
-
38
- describe('ProgramCall Class Unit Tests', function () {
39
- describe('constructor', function () {
40
- it('creates and returns an instance of ProgramCall with lib and function set', function () {
41
- const pgm = new ProgramCall('QTOCNETSTS');
42
- expect(pgm).to.be.instanceOf(ProgramCall);
43
- });
44
- });
45
-
46
- describe('toXML', function () {
47
- it('returns pgm XML', function () {
48
- const pgm = new ProgramCall(
49
- 'QTOCNETSTS',
50
- {
51
- lib: 'QSYS',
52
- func: 'QtoRtvTCPA',
53
- error: 'on',
54
- },
55
- );
56
-
57
- const expectedXML = '<pgm name=\'QTOCNETSTS\' lib=\'QSYS\' func=\'QtoRtvTCPA\' error=\'on\'></pgm>';
58
-
59
- expect(pgm.toXML()).to.be.a('string').and.to.equal(expectedXML);
60
- });
61
- });
62
-
63
- describe('addParam', function () {
64
- it('appends param to pgm xml', function () {
65
- const pgm = new ProgramCall(
66
- 'QTOCNETSTS',
67
- {
68
- lib: 'QSYS',
69
- func: 'QtoRtvTCPA',
70
- error: 'fast',
71
- },
72
- );
73
-
74
- pgm.addParam({ type: 'ds', io: 'out', fields: outBuf });
75
-
76
- let expectedXML = '<pgm name=\'QTOCNETSTS\' lib=\'QSYS\' func=\'QtoRtvTCPA\' error=\'fast\'>'
77
- + '<parm io=\'out\'><ds><data type=\'10i0\'>0</data><data type=\'10i0\'>'
78
- + '0</data><data type=\'36h\'></data><data type=\'10A\'></data>'
79
- + '<data type=\'1A\'></data><data type=\'1A\'></data><data type=\'10i0\'>'
80
- + '0</data><data type=\'10i0\'>0</data></ds></parm></pgm>';
81
-
82
- expect(pgm.toXML()).to.equal(expectedXML);
83
-
84
- pgm.addParam({ value: 66, type: '10i0' });
85
-
86
- expectedXML = '<pgm name=\'QTOCNETSTS\' lib=\'QSYS\' func=\'QtoRtvTCPA\' error=\'fast\'>'
87
- + '<parm io=\'out\'><ds><data type=\'10i0\'>0</data><data type=\'10i0\'>'
88
- + '0</data><data type=\'36h\'></data><data type=\'10A\'></data>'
89
- + '<data type=\'1A\'></data><data type=\'1A\'></data><data type=\'10i0\'>'
90
- + '0</data><data type=\'10i0\'>0</data></ds></parm>'
91
- + '<parm><data type=\'10i0\'>66</data></parm></pgm>';
92
-
93
- expect(pgm.toXML()).to.equal(expectedXML);
94
-
95
- pgm.addParam({ value: 1, type: '10i0' });
96
-
97
- expectedXML = '<pgm name=\'QTOCNETSTS\' lib=\'QSYS\' func=\'QtoRtvTCPA\' error=\'fast\'>'
98
- + '<parm io=\'out\'><ds><data type=\'10i0\'>0</data><data type=\'10i0\'>'
99
- + '0</data><data type=\'36h\'></data><data type=\'10A\'></data>'
100
- + '<data type=\'1A\'></data><data type=\'1A\'></data><data type=\'10i0\'>'
101
- + '0</data><data type=\'10i0\'>0</data></ds></parm>'
102
- + '<parm><data type=\'10i0\'>66</data></parm>'
103
- + '<parm><data type=\'10i0\'>1</data></parm></pgm>';
104
-
105
- expect(pgm.toXML()).to.equal(expectedXML);
106
-
107
- pgm.addParam({ value: 'QCCSID', type: '10A' });
108
-
109
- expectedXML = '<pgm name=\'QTOCNETSTS\' lib=\'QSYS\' func=\'QtoRtvTCPA\' error=\'fast\'>'
110
- + '<parm io=\'out\'><ds><data type=\'10i0\'>0</data><data type=\'10i0\'>'
111
- + '0</data><data type=\'36h\'></data><data type=\'10A\'></data>'
112
- + '<data type=\'1A\'></data><data type=\'1A\'></data><data type=\'10i0\'>'
113
- + '0</data><data type=\'10i0\'>0</data></ds></parm>'
114
- + '<parm><data type=\'10i0\'>66</data></parm>'
115
- + '<parm><data type=\'10i0\'>1</data></parm>'
116
- + '<parm><data type=\'10A\'>QCCSID</data></parm></pgm>';
117
-
118
- expect(pgm.toXML()).to.equal(expectedXML);
119
-
120
- pgm.addParam({
121
- type: 'ds', io: 'both', len: 'rec2', fields: errno,
122
- });
123
-
124
- expectedXML = '<pgm name=\'QTOCNETSTS\' lib=\'QSYS\' func=\'QtoRtvTCPA\' error=\'fast\'>'
125
- + '<parm io=\'out\'><ds><data type=\'10i0\'>0</data><data type=\'10i0\'>'
126
- + '0</data><data type=\'36h\'></data><data type=\'10A\'></data>'
127
- + '<data type=\'1A\'></data><data type=\'1A\'></data><data type=\'10i0\'>'
128
- + '0</data><data type=\'10i0\'>0</data></ds></parm>'
129
- + '<parm><data type=\'10i0\'>66</data></parm>'
130
- + '<parm><data type=\'10i0\'>1</data></parm>'
131
- + '<parm><data type=\'10A\'>QCCSID</data></parm>'
132
- + '<parm io=\'both\'><ds len=\'rec2\'><data type=\'10i0\'>0</data>'
133
- + '<data type=\'10i0\' setlen=\'rec2\'>0</data><data type=\'7A\'>'
134
- + '</data><data type=\'1A\'></data></ds></parm></pgm>';
135
-
136
- expect(pgm.toXML()).to.equal(expectedXML);
137
- });
138
-
139
- it('regular <parm> contains by=\'val\'', function () {
140
- const pgm = new ProgramCall('MYPGM', { lib: 'MYLIB', func: 'MY_PROCEDURE' });
141
-
142
- pgm.addParam({ value: '', type: '1A', by: 'val' });
143
- pgm.addReturn({ name: 'output', type: '2A', value: '' });
144
-
145
- const lookAtXML = pgm.toXML();
146
- expect(lookAtXML).to.match(/<parm .*by='val'.*>/);
147
- });
148
-
149
- it('data structure <parm> contains by=\'val\'', function () {
150
- const pgm = new ProgramCall('MYPGM', { lib: 'MYLIB', func: 'MY_PROCEDURE' });
151
-
152
- const params = [
153
- { type: '3s0', value: 0 },
154
- { type: '7s0', value: 0, name: 'ds_fld2' },
155
- ];
156
-
157
- pgm.addParam({
158
- name: 'inds', type: 'ds', by: 'val', fields: params,
159
- });
160
- pgm.addReturn({ name: 'output', type: '2A', value: '' });
161
-
162
- const lookAtXML = pgm.toXML();
163
- expect(lookAtXML).to.match(/<parm .*by='val'.*>/);
164
- });
165
-
166
- it('regular <parm> contains by=\'val\', with io=\'both\'', function () {
167
- const pgm = new ProgramCall('MYPGM', { lib: 'MYLIB', func: 'MY_PROCEDURE' });
168
-
169
- pgm.addParam({
170
- value: '', type: '1A', by: 'val', io: 'both',
171
- });
172
- pgm.addReturn({ name: 'output', type: '2A', value: '' });
173
-
174
- const lookAtXML = pgm.toXML();
175
- expect(lookAtXML).to.match(/<parm .*by='val'.*>/);
176
- expect(lookAtXML).to.match(/<parm .*io='both'.*>/);
177
- });
178
-
179
- it('data structure <parm> contains by=\'val\', with io=\'both\'', function () {
180
- const pgm = new ProgramCall('MYPGM', { lib: 'MYLIB', func: 'MY_PROCEDURE' });
181
-
182
- const params = [
183
- { type: '3s0', value: 0 },
184
- { type: '7s0', value: 0, name: 'ds_fld2' },
185
- ];
186
-
187
- pgm.addParam({
188
- name: 'inds', type: 'ds', by: 'val', io: 'both', fields: params,
189
- });
190
- pgm.addReturn({ name: 'output', type: '2A', value: '' });
191
-
192
- const lookAtXML = pgm.toXML();
193
- expect(lookAtXML).to.match(/<parm .*by='val'.*>/);
194
- expect(lookAtXML).to.match(/<parm .*io='both'.*>/);
195
- });
196
-
197
- it('add nested data structure parameter', function () {
198
- const pgm = new ProgramCall('MYPGM', { lib: 'MYLIB' });
199
-
200
- const nestedDs = {
201
- name: 'outer-ds',
202
- type: 'ds',
203
- fields: [
204
- {
205
- name: 'sub-ds1',
206
- type: 'ds',
207
- fields: [
208
- { type: '10i0', value: 0 },
209
- { type: '4A', value: 'test' },
210
- ],
211
- },
212
- {
213
- name: 'sub-ds2',
214
- type: 'ds',
215
- fields: [
216
- { type: '20i0', value: 1 },
217
- { type: '6A', value: 'test 2' },
218
- ],
219
- },
220
- ],
221
- };
222
-
223
- pgm.addParam(nestedDs);
224
- const expectedXML = '<pgm name=\'MYPGM\' lib=\'MYLIB\' error=\'fast\'>'
225
- + '<parm name=\'outer-ds\'>'
226
- + '<ds name=\'outer-ds\'>'
227
- + '<ds name=\'sub-ds1\'>'
228
- + '<data type=\'10i0\'>0</data>'
229
- + '<data type=\'4A\'>test</data>'
230
- + '</ds>'
231
- + '<ds name=\'sub-ds2\'>'
232
- + '<data type=\'20i0\'>1</data>'
233
- + '<data type=\'6A\'>test 2</data>'
234
- + '</ds>'
235
- + '</ds>'
236
- + '</parm>'
237
- + '</pgm>';
238
- expect(pgm.toXML()).to.equal(expectedXML);
239
- });
240
- });
241
-
242
- describe('addReturn', function () {
243
- it('appends return to pgm xml', function () {
244
- const pgm = new ProgramCall(
245
- 'QTOCNETSTS',
246
- {
247
- lib: 'QSYS',
248
- func: 'QtoRtvTCPA',
249
- error: 'fast',
250
- },
251
- );
252
-
253
- pgm.addReturn({ type: '20A', value: '0' });
254
-
255
- const expectedXML = '<pgm name=\'QTOCNETSTS\' lib=\'QSYS\' func=\'QtoRtvTCPA\' '
256
- + 'error=\'fast\'><return><data type=\'20A\'>0</data></return></pgm>';
257
-
258
- expect(pgm.toXML()).to.equal(expectedXML);
259
- });
260
-
261
- it('appends return with ds to pgm xml', function () {
262
- const pgm = new ProgramCall('TEST');
263
-
264
- const ds = {
265
- name: 'test_ds',
266
- type: 'ds',
267
- io: 'out',
268
- fields: [
269
- { type: '10i0', value: 0 },
270
- { type: '10A', value: '' },
271
- ],
272
- };
273
- pgm.addReturn(ds);
274
-
275
- const expectedXML = "<pgm name='TEST' error='fast'><return><ds name='test_ds'>"
276
- + "<data type='10i0'>0</data><data type='10A'></data></ds></return></pgm>";
277
-
278
- expect(pgm.toXML()).to.equal(expectedXML);
279
- });
280
- });
281
- });
@@ -1,87 +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 { iSh, iQsh, iCmd } = require('../../../lib/itoolkit');
20
-
21
- describe('iSh, iCmd, iQsh, Unit Tests', function () {
22
- describe('iSh function', function () {
23
- it('accepts command input and returns <sh> XML output', function () {
24
- const sh = iSh('ls -lah');
25
-
26
- const expectedXML = '<sh error=\'fast\'>ls -lah</sh>';
27
-
28
- expect(sh).to.be.a('string').and.to.equal(expectedXML);
29
- });
30
-
31
- it('accepts command input and options returns <sh> with optional attributes', function () {
32
- const options = {
33
- error: 'on', before: '65535', after: '37', rows: 'on',
34
- };
35
-
36
- const sh = iSh('ls -lah', options);
37
-
38
- const expectedXML = '<sh rows=\'on\' before=\'65535\' after=\'37\' error=\'on\'>ls -lah</sh>';
39
-
40
- expect(sh).to.be.a('string').and.to.equal(expectedXML);
41
- });
42
- });
43
-
44
- describe('iCmd function', function () {
45
- it('accepts command input and returns <cmd> XML output', function () {
46
- const cmd = iCmd('RTVJOBA USRLIBL(?) SYSLIBL(?)');
47
-
48
- const expectedXML = '<cmd exec=\'rexx\' error=\'fast\'>RTVJOBA USRLIBL(?) SYSLIBL(?)</cmd>';
49
-
50
- expect(cmd).to.be.a('string').and.to.equal(expectedXML);
51
- });
52
-
53
- it('accepts command input and options returns <cmd> with optional attributes', function () {
54
- const options = {
55
- exec: 'cmd', error: 'on', before: '65535', after: '37', hex: 'on',
56
- };
57
-
58
- const cmd = iCmd('RTVJOBA USRLIBL(?) SYSLIBL(?)', options);
59
-
60
- const expectedXML = '<cmd exec=\'cmd\' hex=\'on\' before=\'65535\' after=\'37\' error=\'on\''
61
- + '>RTVJOBA USRLIBL(?) SYSLIBL(?)</cmd>';
62
-
63
- expect(cmd).to.be.a('string').and.to.equal(expectedXML);
64
- });
65
- });
66
-
67
- describe('iQsh function', function () {
68
- it('accepts command input and returns <qsh> XML output', function () {
69
- const qsh = iQsh('RTVJOBA USRLIBL(?) SYSLIBL(?)');
70
-
71
- const expectedXML = '<qsh error=\'fast\'>RTVJOBA USRLIBL(?) SYSLIBL(?)</qsh>';
72
-
73
- expect(qsh).to.be.a('string').and.to.equal(expectedXML);
74
- });
75
-
76
- it('accepts command input and options returns <qsh> with optional attributes', function () {
77
- const options = {
78
- error: 'on', before: '65535', after: '37', rows: 'on',
79
- };
80
- const qsh = iQsh('ls -lah', options);
81
-
82
- const expectedXML = '<qsh rows=\'on\' before=\'65535\' after=\'37\' error=\'on\'>ls -lah</qsh>';
83
-
84
- expect(qsh).to.be.a('string').and.to.equal(expectedXML);
85
- });
86
- });
87
- });
@@ -1,158 +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 sinon = require('sinon');
22
- const { iConn, iSh } = require('../../../lib/itoolkit');
23
-
24
- describe('iConn Class Unit Tests', function () {
25
- describe('constructor', function () {
26
- it('creates and returns an instance of iConn with idb transport', function () {
27
- const database = process.env.TKDB || '*LOCAL';
28
- const username = process.env.TKUSER || '';
29
- const password = process.env.TKPASS || '';
30
-
31
- const connection = new iConn(database, username, password);
32
-
33
- expect(connection).to.be.instanceOf(iConn);
34
- expect(connection.connection.transportOptions).to.be.an('Object');
35
- expect(connection.connection.transportOptions.database).to.equal(database);
36
- expect(connection.connection.transportOptions.username).to.equal(username);
37
- expect(connection.connection.transportOptions.password).to.equal(password);
38
- expect(connection.connection.transport).to.equal('idb');
39
- expect(connection.connection.commandList).to.be.an('Array');
40
- expect(connection.connection.commandList.length).to.equal(0);
41
- expect(connection.connection.verbose).to.equal(false);
42
- });
43
-
44
- it('creates and returns an instance of iConn with rest transport', function () {
45
- const database = process.env.TKDB || '*LOCAL';
46
- const username = process.env.TKUSER || '';
47
- const password = process.env.TKPASS || '';
48
-
49
- const options = {
50
- host: process.env.TKHOST || 'localhost',
51
- port: process.env.TKPORT || 80,
52
- path: process.env.TKPATH || '/cgi-bin/xmlcgi.pgm',
53
- xslib: 'QXMLSERV',
54
- ipc: '*NA',
55
- ctl: '*here',
56
- };
57
-
58
- const connection = new iConn(database, username, password, options);
59
-
60
- expect(connection).to.be.instanceOf(iConn);
61
- expect(connection.connection.transportOptions).to.be.an('Object');
62
- expect(connection.connection.transportOptions.database).to.equal(database);
63
- expect(connection.connection.transportOptions.username).to.equal(username);
64
- expect(connection.connection.transportOptions.password).to.equal(password);
65
- expect(connection.connection.transport).to.equal('rest');
66
- expect(connection.connection.transportOptions.ctl).to.equal('*here');
67
- expect(connection.connection.transportOptions.ipc).to.equal('*NA');
68
- expect(connection.connection.transportOptions.xslib).to.equal('QXMLSERV');
69
- expect(connection.connection.commandList).to.be.an('Array');
70
- expect(connection.connection.commandList.length).to.equal(0);
71
- expect(connection.connection.verbose).to.equal(false);
72
- });
73
- });
74
-
75
- describe('add', function () {
76
- it('appends to xml service request to the command list using iConn class', function () {
77
- const database = process.env.TKDB || '*LOCAL';
78
- const username = process.env.TKUSER || '';
79
- const password = process.env.TKPASS || '';
80
- const connection = new iConn(database, username, password);
81
-
82
- connection.add(iSh('ls -lah'));
83
- expect(connection.connection.commandList.length).to.equal(1);
84
- expect(connection.connection.commandList[0]).to.equal('<sh error=\'fast\'>ls -lah</sh>');
85
- });
86
- });
87
-
88
- describe('debug', function () {
89
- it('turns verbose mode on/off using iConn class', function () {
90
- const database = process.env.TKDB || '*LOCAL';
91
- const username = process.env.TKUSER || '';
92
- const password = process.env.TKPASS || '';
93
- const connection = new iConn(database, username, password);
94
-
95
- connection.debug(true);
96
- expect(connection.debug()).to.equal(true);
97
- connection.debug(false);
98
- expect(connection.debug()).to.equal(false);
99
- });
100
- });
101
-
102
- describe('getTransportOptions', function () {
103
- it('returns conn (object) property from iConn instance', function () {
104
- const database = process.env.TKDB || '*LOCAL';
105
- const username = process.env.TKUSER || '';
106
- const password = process.env.TKPASS || '';
107
-
108
- const connection = new iConn(database, username, password);
109
-
110
- // iConn.getConnection() calls -> Connection.getTransportOptions()
111
- const options = connection.getConnection();
112
-
113
- expect(options).to.be.an('Object');
114
- expect(options.database).to.equal(database);
115
- expect(options.username).to.equal(username);
116
- expect(options.password).to.equal(password);
117
- });
118
- });
119
-
120
- describe('run', function () {
121
- it('(iConn) invokes transport to execute xml input and returns xml output in callback', function () {
122
- const database = process.env.TKDB || '*LOCAL';
123
- const username = process.env.TKUSER || '';
124
- const password = process.env.TKPASS || '';
125
-
126
- const connection = new iConn(database, username, password);
127
- const xmlOut = `<?xml version='1.0'?><myscript><sql>
128
- <query error='fast' conn='conn1' stmt='stmt1'>
129
- <success><![CDATA[+++ success SELECT LSTNAM, STATE FROM QIWS.QCUSTCDT]]></success>
130
- </query>
131
- <fetch block='all' desc='on' stmt='stmt1'>
132
- <row><data desc='LSTNAM'>Henning</data><data desc='STATE'>TX</data></row>
133
- <row><data desc='LSTNAM'>Jones</data><data desc='STATE'>NY</data></row>
134
- <row><data desc='LSTNAM'>Vine</data><data desc='STATE'>VT</data></row>
135
- <row><data desc='LSTNAM'>Johnson</data><data desc='STATE'>GA</data></row>
136
- <row><data desc='LSTNAM'>Tyron</data><data desc='STATE'>NY</data></row>
137
- <row><data desc='LSTNAM'>Stevens</data><data desc='STATE'>CO</data></row>
138
- <row><data desc='LSTNAM'>Alison</data><data desc='STATE'>MN</data></row>
139
- <row><data desc='LSTNAM'>Doe</data><data desc='STATE'>CA</data></row>
140
- <row><data desc='LSTNAM'>Thomas</data><data desc='STATE'>WY</data></row>
141
- <row><data desc='LSTNAM'>Williams</data><data desc='STATE'>TX</data></row>
142
- <row><data desc='LSTNAM'>Lee</data><data desc='STATE'>NY</data></row>
143
- <row><data desc='LSTNAM'>Abraham</data><data desc='STATE'>MN</data></row>
144
- <success>+++ success stmt1</success>
145
- </fetch>
146
- <free><success>+++ success </success>
147
- </free>
148
- </sql>
149
- </myscript>`;
150
-
151
- sinon.stub(connection, 'run').yields(xmlOut);
152
-
153
- connection.run((result) => {
154
- expect(result).to.equal(xmlOut);
155
- });
156
- });
157
- });
158
- });