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