itoolkit 1.0.0 → 1.0.2

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 (45) hide show
  1. package/README.md +13 -8
  2. package/lib/CommandCall.js +2 -16
  3. package/lib/Connection.js +2 -17
  4. package/lib/Deprecated.js +5 -26
  5. package/lib/ProgramCall.js +4 -18
  6. package/lib/itoolkit.js +2 -16
  7. package/lib/transports/httpTransport.js +4 -18
  8. package/lib/transports/idbTransport.js +24 -26
  9. package/lib/transports/odbcTransport.js +16 -16
  10. package/lib/transports/sshTransport.js +5 -20
  11. package/package.json +23 -16
  12. package/.eslintrc.js +0 -13
  13. package/.gitattributes +0 -2
  14. package/.readthedocs.yml +0 -16
  15. package/CHANGELOG.md +0 -195
  16. package/contributors.txt +0 -2
  17. package/test/README.md +0 -46
  18. package/test/functional/CommandCallFunctional.js +0 -79
  19. package/test/functional/ProgramCallFunctional.js +0 -166
  20. package/test/functional/checkObjectExists.js +0 -182
  21. package/test/functional/config.js +0 -35
  22. package/test/functional/deprecated/commandsFunctional.js +0 -99
  23. package/test/functional/deprecated/iDataQueueFunctional.js +0 -104
  24. package/test/functional/deprecated/iNetworkFunctional.js +0 -160
  25. package/test/functional/deprecated/iObjFunctional.js +0 -350
  26. package/test/functional/deprecated/iPgmFunctional.js +0 -140
  27. package/test/functional/deprecated/iProdFunctional.js +0 -161
  28. package/test/functional/deprecated/iSqlFunctional.js +0 -455
  29. package/test/functional/deprecated/iUserSpaceFunctional.js +0 -127
  30. package/test/functional/deprecated/iWorkFunctional.js +0 -236
  31. package/test/functional/iDataQueueFunctional.js +0 -84
  32. package/test/functional/iNetworkFunctional.js +0 -133
  33. package/test/functional/iObjFunctional.js +0 -327
  34. package/test/functional/iProdFunctional.js +0 -135
  35. package/test/functional/iSqlFunctional.js +0 -449
  36. package/test/functional/iUserSpaceFunctional.js +0 -123
  37. package/test/functional/iWorkFunctional.js +0 -219
  38. package/test/unit/CommandCallUnit.js +0 -88
  39. package/test/unit/ConnectionUnit.js +0 -195
  40. package/test/unit/ProgamCallUnit.js +0 -279
  41. package/test/unit/deprecated/commandsUnit.js +0 -88
  42. package/test/unit/deprecated/iConnUnit.js +0 -162
  43. package/test/unit/deprecated/iPgmUnit.js +0 -207
  44. package/test/unit/deprecated/iSqlUnit.js +0 -442
  45. package/test/unit/deprecated/xmlToJsonUnit.js +0 -203
@@ -1,455 +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-env mocha */
19
- /* eslint-disable new-cap */
20
-
21
-
22
- const { expect } = require('chai');
23
- const { parseString } = require('xml2js');
24
- const { iSql, iConn } = require('../../../lib/itoolkit');
25
- const { config, printConfig } = require('../config');
26
-
27
- // deprecated tests are in place to test compatability using deprecated classes and functions
28
- // these tests use deprecated iConn Class to create a connnection
29
- // iConn only supported idb and rest transports
30
- if (config.transport !== 'idb' && config.transport !== 'rest') {
31
- throw new Error('Only idb and rest transports are available for deprecated tests');
32
- }
33
-
34
- const {
35
- database, username, password, host, port = 80, path,
36
- } = config.transportOptions;
37
-
38
- let restOptions = null;
39
- if (config.transport === 'rest') {
40
- restOptions = {
41
- host,
42
- port,
43
- path,
44
- };
45
- }
46
-
47
- describe('iSql Functional Tests', () => {
48
- before(() => {
49
- printConfig();
50
- });
51
-
52
- describe('prepare & execute', () => {
53
- it('prepares & executes stored procedure then fetch results', (done) => {
54
- const connection = new iConn(database, username, password, restOptions);
55
-
56
- const sql = new iSql();
57
-
58
- sql.prepare('call qsys2.tcpip_info()');
59
- sql.execute();
60
- sql.fetch();
61
- sql.free();
62
- connection.add(sql);
63
- connection.run((xmlOut) => {
64
- parseString(xmlOut, (parseError, result) => {
65
- expect(parseError).to.equal(null);
66
- const sqlNode = result.myscript.sql[0];
67
- expect(sqlNode.prepare[0].success[0]).to.include('+++ success');
68
- expect(sqlNode.execute[0].success[0]).to.include('+++ success');
69
- expect(sqlNode.fetch[0].success[0]).to.include('+++ success');
70
- expect(sqlNode.free[0].success[0]).to.include('+++ success');
71
- const { data } = result.myscript.sql[0].fetch[0].row[0];
72
- expect(data[0].$.desc).to.equal('HOSTNAME');
73
- expect(data[1].$.desc).to.equal('VRM');
74
- expect(data[2].$.desc).to.equal('DBGROUP');
75
- expect(data[3].$.desc).to.equal('IPTYPE');
76
- expect(data[4].$.desc).to.equal('IPADDR');
77
- expect(data[5].$.desc).to.equal('PORT');
78
- done();
79
- });
80
- });
81
- });
82
- });
83
-
84
- describe('addQuery & fetch', () => {
85
- it('runs a query and fetches results', (done) => {
86
- const connection = new iConn(database, username, password, restOptions);
87
-
88
- const sql = new iSql();
89
-
90
- sql.addQuery('SELECT LSTNAM, STATE FROM QIWS.QCUSTCDT');
91
- sql.fetch();
92
- sql.free();
93
- connection.add(sql);
94
- connection.run((xmlOut) => {
95
- parseString(xmlOut, (parseError, result) => {
96
- expect(parseError).to.equal(null);
97
- const sqlNode = result.myscript.sql[0];
98
- expect(sqlNode.query[0].success[0]).to.include('+++ success');
99
- expect(sqlNode.fetch[0].success[0]).to.include('+++ success');
100
- expect(sqlNode.free[0].success[0]).to.include('+++ success');
101
- expect(sqlNode.fetch[0].row[0].data[0].$.desc).to.equal('LSTNAM');
102
- expect(sqlNode.fetch[0].row[0].data[1].$.desc).to.equal('STATE');
103
- done();
104
- });
105
- });
106
- });
107
- });
108
-
109
- describe('added test to ensure issue #11 was resolved', () => {
110
- it('should parse SQL result set empty data tags correctly', (done) => {
111
- const connection = new iConn(database, username, password, restOptions);
112
-
113
- const sql = new iSql();
114
-
115
- sql.addQuery('SELECT \'\' AS BLANK, STATE FROM QIWS.QCUSTCDT');
116
- sql.fetch();
117
- sql.free();
118
- connection.add(sql);
119
- connection.run((xmlOut) => {
120
- parseString(xmlOut, (parseError, result) => {
121
- expect(parseError).to.equal(null);
122
- const sqlNode = result.myscript.sql[0];
123
- expect(sqlNode.query[0].success[0]).to.include('+++ success');
124
- expect(sqlNode.fetch[0].success[0]).to.include('+++ success');
125
- expect(sqlNode.free[0].success[0]).to.include('+++ success');
126
- expect(sqlNode.fetch[0].row[0].data[0].$.desc).to.equal('BLANK');
127
- // xml2js no inner data gets parsed as undefined.
128
- expect(sqlNode.fetch[0].row[0].data[0]._).to.equal(undefined);
129
- done();
130
- });
131
- });
132
- });
133
- });
134
-
135
- describe('tables', () => {
136
- it('returns meta data for specified table', (done) => {
137
- const connection = new iConn(database, username, password, restOptions);
138
-
139
- const sql = new iSql();
140
- // [catalog, schema, table, table type]
141
- sql.tables(['', 'QIWS', 'QCUSTCDT', '']);
142
- connection.add(sql.toXML());
143
- connection.run((xmlOut) => {
144
- parseString(xmlOut, (parseError, result) => {
145
- expect(parseError).to.equal(null);
146
- expect(result.myscript.sql[0].tables[0].success[0]).to.include('+++ success');
147
- const { data } = result.myscript.sql[0].tables[0].row[0];
148
- expect(data[0].$.desc).to.equal('TABLE_CAT');
149
- expect(data[1].$.desc).to.equal('TABLE_SCHEM');
150
- expect(data[2].$.desc).to.equal('TABLE_NAME');
151
- expect(data[3].$.desc).to.equal('TABLE_TYPE');
152
- expect(data[4].$.desc).to.equal('REMARKS');
153
- done();
154
- });
155
- });
156
- });
157
- });
158
-
159
- describe('tablePriv', () => {
160
- it('returns privilege data for a table', (done) => {
161
- const connection = new iConn(database, username, password, restOptions);
162
-
163
- const sql = new iSql();
164
- // [catalog, schema, table]
165
- sql.tablePriv(['', 'QIWS', 'QCUSTCDT']);
166
- connection.add(sql.toXML());
167
- connection.run((xmlOut) => {
168
- parseString(xmlOut, (parseError, result) => {
169
- expect(parseError).to.equal(null);
170
- expect(result.myscript.sql[0].tablepriv[0].success[0]).to.include('+++ success');
171
- const { data } = result.myscript.sql[0].tablepriv[0].row[0];
172
- expect(data[0].$.desc).to.equal('TABLE_CAT');
173
- expect(data[1].$.desc).to.equal('TABLE_SCHEM');
174
- expect(data[2].$.desc).to.equal('TABLE_NAME');
175
- expect(data[3].$.desc).to.equal('GRANTOR');
176
- expect(data[4].$.desc).to.equal('GRANTEE');
177
- expect(data[5].$.desc).to.equal('PRIVILEGE');
178
- expect(data[6].$.desc).to.equal('IS_GRANTABLE');
179
- done();
180
- });
181
- });
182
- });
183
- });
184
-
185
- describe('columns', () => {
186
- it('returns meta data for a column', (done) => {
187
- const connection = new iConn(database, username, password, restOptions);
188
-
189
- const sql = new iSql();
190
- // catalog, schema, table, column
191
- sql.columns(['', 'QIWS', 'QCUSTCDT', 'CUSNUM']);
192
- connection.add(sql.toXML());
193
- connection.run((xmlOut) => {
194
- parseString(xmlOut, (parseError, result) => {
195
- expect(parseError).to.equal(null);
196
- expect(result.myscript.sql[0].columns[0].success[0]).to.include('+++ success');
197
- const { data } = result.myscript.sql[0].columns[0].row[0];
198
- expect(data[0].$.desc).to.equal('TABLE_CAT');
199
- expect(data[1].$.desc).to.equal('TABLE_SCHEM');
200
- expect(data[2].$.desc).to.equal('TABLE_NAME');
201
- expect(data[3].$.desc).to.equal('COLUMN_NAME');
202
- expect(data[4].$.desc).to.equal('DATA_TYPE');
203
- expect(data[5].$.desc).to.equal('TYPE_NAME');
204
- expect(data[6].$.desc).to.equal('COLUMN_SIZE');
205
- expect(data[7].$.desc).to.equal('BUFFER_LENGTH');
206
- expect(data[8].$.desc).to.equal('DECIMAL_DIGITS');
207
- expect(data[9].$.desc).to.equal('NUM_PREC_RADIX');
208
- expect(data[10].$.desc).to.equal('NULLABLE');
209
- expect(data[11].$.desc).to.equal('REMARKS');
210
- expect(data[12].$.desc).to.equal('COLUMN_DEF');
211
- expect(data[13].$.desc).to.equal('SQL_DATA_TYPE');
212
- expect(data[14].$.desc).to.equal('SQL_DATETIME_SUB');
213
- expect(data[15].$.desc).to.equal('CHAR_OCTET_LENGTH');
214
- expect(data[16].$.desc).to.equal('ORDINAL_POSITION');
215
- expect(data[17].$.desc).to.equal('IS_NULLABLE');
216
- done();
217
- });
218
- });
219
- });
220
- });
221
-
222
- describe('columnPriv', () => {
223
- it('returns privilege data for a column', (done) => {
224
- const connection = new iConn(database, username, password, restOptions);
225
-
226
- const sql = new iSql();
227
-
228
- sql.columnPriv(['', 'QIWS', 'QCUSTCDT', 'BALDUE']);
229
-
230
- connection.add(sql.toXML());
231
- connection.run((xmlOut) => {
232
- parseString(xmlOut, (parseError, result) => {
233
- expect(parseError).to.equal(null);
234
- expect(result.myscript.sql[0].columnpriv[0].success[0]).to.include('+++ success');
235
- const { data } = result.myscript.sql[0].columnpriv[0].row[0];
236
- expect(data[0].$.desc).to.equal('TABLE_CAT');
237
- expect(data[1].$.desc).to.equal('TABLE_SCHEM');
238
- expect(data[2].$.desc).to.equal('TABLE_NAME');
239
- expect(data[3].$.desc).to.equal('COLUMN_NAME');
240
- expect(data[4].$.desc).to.equal('GRANTOR');
241
- expect(data[5].$.desc).to.equal('GRANTEE');
242
- expect(data[6].$.desc).to.equal('PRIVILEGE');
243
- expect(data[7].$.desc).to.equal('IS_GRANTABLE');
244
- done();
245
- });
246
- });
247
- });
248
- });
249
-
250
- describe('procedures', () => {
251
- it('returns meta data on for a procedure', (done) => {
252
- const connection = new iConn(database, username, password, restOptions);
253
-
254
- const sql = new iSql();
255
- // [catalog, schema, procedure]
256
- sql.procedures(['', 'QSYS2', 'TCPIP_INFO']);
257
- connection.add(sql.toXML());
258
- connection.run((xmlOut) => {
259
- parseString(xmlOut, (parseError, result) => {
260
- expect(parseError).to.equal(null);
261
- expect(result.myscript.sql[0].procedures[0].success[0]).to.include('+++ success');
262
- const { data } = result.myscript.sql[0].procedures[0].row[0];
263
- expect(data[0].$.desc).to.equal('PROCEDURE_CAT');
264
- expect(data[1].$.desc).to.equal('PROCEDURE_SCHEM');
265
- expect(data[2].$.desc).to.equal('PROCEDURE_NAME');
266
- expect(data[3].$.desc).to.equal('NUM_INPUT_PARAMS');
267
- expect(data[4].$.desc).to.equal('NUM_OUTPUT_PARAMS');
268
- expect(data[5].$.desc).to.equal('NUM_RESULT_SETS');
269
- expect(data[6].$.desc).to.equal('REMARKS');
270
- expect(data[7].$.desc).to.equal('PROCEDURE_TYPE');
271
- done();
272
- });
273
- });
274
- });
275
- });
276
-
277
- describe('pColumns', () => {
278
- it('returns meta data for procedure column', (done) => {
279
- const connection = new iConn(database, username, password, restOptions);
280
-
281
- const sql = new iSql();
282
- // [catalog, schema, procedure, column]
283
- sql.pColumns(['', 'QSYS2', 'QCMDEXC', 'COMMAND']);
284
- connection.add(sql.toXML());
285
- connection.run((xmlOut) => {
286
- parseString(xmlOut, (parseError, result) => {
287
- expect(parseError).to.equal(null);
288
- expect(result.myscript.sql[0].pcolumns[0].success[0]).to.include('+++ success');
289
- const { data } = result.myscript.sql[0].pcolumns[0].row[0];
290
- expect(data[0].$.desc).to.equal('PROCEDURE_CAT');
291
- expect(data[1].$.desc).to.equal('PROCEDURE_SCHEM');
292
- expect(data[2].$.desc).to.equal('PROCEDURE_NAME');
293
- expect(data[3].$.desc).to.equal('COLUMN_NAME');
294
- expect(data[4].$.desc).to.equal('COLUMN_TYPE');
295
- expect(data[5].$.desc).to.equal('DATA_TYPE');
296
- expect(data[6].$.desc).to.equal('TYPE_NAME');
297
- expect(data[7].$.desc).to.equal('COLUMN_SIZE');
298
- expect(data[8].$.desc).to.equal('BUFFER_LENGTH');
299
- expect(data[9].$.desc).to.equal('DECIMAL_DIGITS');
300
- expect(data[10].$.desc).to.equal('NUM_PREC_RADIX');
301
- expect(data[11].$.desc).to.equal('NULLABLE');
302
- expect(data[12].$.desc).to.equal('REMARKS');
303
- expect(data[13].$.desc).to.equal('COLUMN_DEF');
304
- expect(data[14].$.desc).to.equal('SQL_DATA_TYPE');
305
- expect(data[15].$.desc).to.equal('SQL_DATETIME_SUB');
306
- expect(data[16].$.desc).to.equal('CHAR_OCTET_LENGTH');
307
- expect(data[17].$.desc).to.equal('ORDINAL_POSITION');
308
- expect(data[18].$.desc).to.equal('IS_NULLABLE');
309
- done();
310
- });
311
- });
312
- });
313
- });
314
-
315
- describe('primaryKeys', () => {
316
- it('returns meta data for a primary key', (done) => {
317
- const connection = new iConn(database, username, password, restOptions);
318
-
319
- const sql = new iSql();
320
- // [catalog, schema, table]
321
- sql.primaryKeys(['', 'QUSRSYS', 'QASZRAIRX']);
322
- connection.add(sql.toXML());
323
- connection.run((xmlOut) => {
324
- parseString(xmlOut, (parseError, result) => {
325
- expect(parseError).to.equal(null);
326
- expect(result.myscript.sql[0].primarykeys[0].success[0]).to.include('+++ success');
327
- const { data } = result.myscript.sql[0].primarykeys[0].row[0];
328
- expect(data[0].$.desc).to.equal('TABLE_CAT');
329
- expect(data[1].$.desc).to.equal('TABLE_SCHEM');
330
- expect(data[2].$.desc).to.equal('TABLE_NAME');
331
- expect(data[3].$.desc).to.equal('COLUMN_NAME');
332
- expect(data[4].$.desc).to.equal('KEY_SEQ');
333
- expect(data[5].$.desc).to.equal('PK_NAME');
334
- done();
335
- });
336
- });
337
- });
338
- });
339
-
340
- describe('foreignKeys', () => {
341
- it('returns meta data for a foreign key', (done) => {
342
- const connection = new iConn(database, username, password, restOptions);
343
-
344
- const sql = new iSql();
345
- // pk: [catalog, schema, table]
346
- // fk: [catalog, schema, table]
347
- sql.foreignKeys(['', 'QUSRSYS', 'QASZRAIRC', '', 'QUSRSYS', 'QASZRAIRX']);
348
- connection.add(sql.toXML());
349
- connection.run((xmlOut) => {
350
- parseString(xmlOut, (parseError, result) => {
351
- expect(parseError).to.equal(null);
352
- expect(result.myscript.sql[0].foreignkeys[0].success[0]).to.include('+++ success');
353
- const { data } = result.myscript.sql[0].foreignkeys[0].row[0];
354
- expect(data[0].$.desc).to.equal('PKTABLE_CAT');
355
- expect(data[1].$.desc).to.equal('PKTABLE_SCHEM');
356
- expect(data[2].$.desc).to.equal('PKTABLE_NAME');
357
- expect(data[3].$.desc).to.equal('PKCOLUMN_NAME');
358
- expect(data[4].$.desc).to.equal('FKTABLE_CAT');
359
- expect(data[5].$.desc).to.equal('FKTABLE_SCHEM');
360
- expect(data[6].$.desc).to.equal('FKTABLE_NAME');
361
- expect(data[7].$.desc).to.equal('FKCOLUMN_NAME');
362
- expect(data[8].$.desc).to.equal('KEY_SEQ');
363
- expect(data[9].$.desc).to.equal('UPDATE_RULE');
364
- expect(data[10].$.desc).to.equal('DELETE_RULE');
365
- expect(data[11].$.desc).to.equal('FK_NAME');
366
- expect(data[12].$.desc).to.equal('PK_NAME');
367
- expect(data[13].$.desc).to.equal('DEFERRABILITY');
368
- done();
369
- });
370
- });
371
- });
372
- });
373
-
374
- describe('statistics', () => {
375
- it('returns stats info for table', (done) => {
376
- const connection = new iConn(database, username, password, restOptions);
377
-
378
- const sql = new iSql();
379
-
380
- sql.statistics(['', 'QIWS', 'QCUSTCDT', 'all']);
381
- connection.add(sql.toXML());
382
- connection.run((xmlOut) => {
383
- parseString(xmlOut, (parseError, result) => {
384
- expect(parseError).to.equal(null);
385
- expect(result.myscript.sql[0].statistics[0].success[0]).to.include('+++ success');
386
- const { data } = result.myscript.sql[0].statistics[0].row[0];
387
- expect(data[0].$.desc).to.equal('TABLE_CAT');
388
- expect(data[1].$.desc).to.equal('TABLE_SCHEM');
389
- expect(data[2].$.desc).to.equal('TABLE_NAME');
390
- expect(data[3].$.desc).to.equal('NON_UNIQUE');
391
- expect(data[4].$.desc).to.equal('INDEX_QUALIFIER');
392
- expect(data[5].$.desc).to.equal('INDEX_NAME');
393
- expect(data[6].$.desc).to.equal('TYPE');
394
- expect(data[7].$.desc).to.equal('ORDINAL_POSITION');
395
- expect(data[8].$.desc).to.equal('COLUMN_NAME');
396
- expect(data[9].$.desc).to.equal('ASC_OR_DESC');
397
- expect(data[10].$.desc).to.equal('CARDINALITY');
398
- expect(data[11].$.desc).to.equal('PAGES');
399
- expect(data[12].$.desc).to.equal('FILTER_CONDITION');
400
- done();
401
- });
402
- });
403
- });
404
- });
405
-
406
- describe.skip('special', () => {
407
- // TODO: find passing case
408
- // Below test fails with error code 9- argument value not valid
409
- it.skip('returns meta data for special columns', (done) => {
410
- // [catalog, schema, table, row | transaction |session, no | nullable]
411
- const connection = new iConn(database, username, password, restOptions);
412
-
413
- const sql = new iSql();
414
-
415
- sql.special(['', 'QUSRSYS', 'QASZRAIRX', 'row', 'no'], { error: 'on' });
416
- connection.add(sql.toXML());
417
- connection.debug(true);
418
- connection.run((xmlOut) => {
419
- parseString(xmlOut, (parseError, result) => {
420
- expect(parseError).to.equal(null);
421
- // TODO add more assertions
422
- expect(result).to.be.an('object');
423
- done();
424
- });
425
- });
426
- });
427
- });
428
-
429
- describe.skip('rowCount', () => {
430
- // Skip for now need to create a table for this test to insert to.
431
- it.skip('returns the number of rows affected by statement', (done) => {
432
- const connection = new iConn(database, username, password, restOptions);
433
-
434
- const sql = new iSql();
435
-
436
- const insert = 'INSERT INTO QIWS.QCUSTCDT (CUSNUM,LSTNAM,INIT,STREET,CITY,STATE,ZIPCOD,CDTLMT,CHGCOD,BALDUE,CDTDUE) '
437
- + 'VALUES (8798,\'TURNER\',\'TT\',\'MAIN\',\'NYC\',\'NY\',10001, 500, 3, 40.00, 0.00) with NONE';
438
-
439
- sql.addQuery(insert);
440
- sql.rowCount();
441
- sql.free();
442
- connection.add(sql.toXML());
443
- connection.run((xmlOut) => {
444
- parseString(xmlOut, (parseError, result) => {
445
- const sqlNode = result.myscript.sql[0];
446
- expect(parseError).to.equal(null);
447
- expect(sqlNode.query[0].success[0]).to.include('+++ success');
448
- expect(sqlNode.free[0].success[0]).to.include('+++ success');
449
- expect(sqlNode.rowcount[0]._).to.equal('1');
450
- done();
451
- });
452
- });
453
- });
454
- });
455
- });
@@ -1,127 +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-env mocha */
19
- /* eslint-disable new-cap */
20
-
21
- const { expect } = require('chai');
22
- const { iConn, iUserSpace } = require('../../../lib/itoolkit');
23
- const { config, printConfig } = require('../config');
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';
46
-
47
- describe('iUserSpace Functional Tests', () => {
48
- before(() => {
49
- printConfig();
50
- });
51
-
52
- describe('constructor', () => {
53
- it('returns an instance of iUserSpace', () => {
54
- const connection = new iConn(database, config.user, password);
55
-
56
- const userSpace = new iUserSpace(connection);
57
-
58
- expect(userSpace).to.be.instanceOf(iUserSpace);
59
- });
60
- });
61
-
62
- describe('createUserSpace', () => {
63
- it('creates a user space', (done) => {
64
- const connection = new iConn(database, username, password, restOptions);
65
-
66
- const userSpace = new iUserSpace(connection);
67
-
68
- const description = 'Node toolkit test user space';
69
-
70
- const userSpaceName = `USP${(config.transport).toUpperCase()}`;
71
-
72
- userSpace.createUserSpace(userSpaceName, lib, 'LOG', 50, '*EXCLUDE',
73
- description, (output) => {
74
- expect(output).to.be.a('boolean').and.to.equal(true);
75
- done();
76
- });
77
- });
78
- });
79
-
80
- describe('setUserSpaceData', () => {
81
- it('sets data within the user space', (done) => {
82
- const connection = new iConn(database, username, password, restOptions);
83
-
84
- const userSpace = new iUserSpace(connection);
85
-
86
- const msg = 'Hello from userspace!';
87
-
88
- const userSpaceName = `USP${(config.transport).toUpperCase()}`;
89
-
90
- userSpace.setUserSpaceData(userSpaceName, lib, msg.length, msg,
91
- (output) => {
92
- expect(output).to.be.a('boolean').and.to.equal(true);
93
- done();
94
- });
95
- });
96
- });
97
-
98
- describe('getUserSpaceData', () => {
99
- it('returns specified length of data', (done) => {
100
- const connection = new iConn(database, username, password, restOptions);
101
-
102
- const userSpace = new iUserSpace(connection);
103
-
104
- const userSpaceName = `USP${(config.transport).toUpperCase()}`;
105
-
106
- userSpace.getUserSpaceData(userSpaceName, lib, 21, (output) => {
107
- expect(output).to.be.a('string').and.to.equal('Hello from userspace!');
108
- done();
109
- });
110
- });
111
- });
112
-
113
- describe('deleteUserSpace', () => {
114
- it('removes a user space', (done) => {
115
- const connection = new iConn(database, username, password, restOptions);
116
-
117
- const userSpace = new iUserSpace(connection);
118
-
119
- const userSpaceName = `USP${(config.transport).toUpperCase()}`;
120
-
121
- userSpace.deleteUserSpace(userSpaceName, lib, (output) => {
122
- expect(output).to.be.a('boolean').and.to.equal(true);
123
- done();
124
- });
125
- });
126
- });
127
- });