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