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.
- package/README.md +13 -8
- package/lib/CommandCall.js +2 -16
- package/lib/Connection.js +2 -17
- package/lib/Deprecated.js +5 -26
- package/lib/ProgramCall.js +4 -18
- package/lib/itoolkit.js +2 -16
- package/lib/transports/httpTransport.js +4 -18
- package/lib/transports/idbTransport.js +24 -26
- package/lib/transports/odbcTransport.js +16 -16
- package/lib/transports/sshTransport.js +5 -20
- package/package.json +23 -16
- package/.eslintrc.js +0 -13
- package/.gitattributes +0 -2
- package/.readthedocs.yml +0 -16
- package/CHANGELOG.md +0 -195
- package/contributors.txt +0 -2
- package/test/README.md +0 -46
- package/test/functional/CommandCallFunctional.js +0 -79
- package/test/functional/ProgramCallFunctional.js +0 -166
- package/test/functional/checkObjectExists.js +0 -182
- package/test/functional/config.js +0 -35
- package/test/functional/deprecated/commandsFunctional.js +0 -99
- package/test/functional/deprecated/iDataQueueFunctional.js +0 -104
- package/test/functional/deprecated/iNetworkFunctional.js +0 -160
- package/test/functional/deprecated/iObjFunctional.js +0 -350
- package/test/functional/deprecated/iPgmFunctional.js +0 -140
- package/test/functional/deprecated/iProdFunctional.js +0 -161
- package/test/functional/deprecated/iSqlFunctional.js +0 -455
- package/test/functional/deprecated/iUserSpaceFunctional.js +0 -127
- package/test/functional/deprecated/iWorkFunctional.js +0 -236
- package/test/functional/iDataQueueFunctional.js +0 -84
- package/test/functional/iNetworkFunctional.js +0 -133
- package/test/functional/iObjFunctional.js +0 -327
- package/test/functional/iProdFunctional.js +0 -135
- package/test/functional/iSqlFunctional.js +0 -449
- package/test/functional/iUserSpaceFunctional.js +0 -123
- package/test/functional/iWorkFunctional.js +0 -219
- package/test/unit/CommandCallUnit.js +0 -88
- package/test/unit/ConnectionUnit.js +0 -195
- package/test/unit/ProgamCallUnit.js +0 -279
- package/test/unit/deprecated/commandsUnit.js +0 -88
- package/test/unit/deprecated/iConnUnit.js +0 -162
- package/test/unit/deprecated/iPgmUnit.js +0 -207
- package/test/unit/deprecated/iSqlUnit.js +0 -442
- package/test/unit/deprecated/xmlToJsonUnit.js +0 -203
|
@@ -1,207 +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 { iPgm } = require('../../../lib/itoolkit');
|
|
23
|
-
|
|
24
|
-
const outBuf = [
|
|
25
|
-
[0, '10i0'],
|
|
26
|
-
[0, '10i0'],
|
|
27
|
-
['', '36h'],
|
|
28
|
-
['', '10A'],
|
|
29
|
-
['', '1A'],
|
|
30
|
-
['', '1A'],
|
|
31
|
-
[0, '10i0'],
|
|
32
|
-
[0, '10i0'],
|
|
33
|
-
];
|
|
34
|
-
const errno = [
|
|
35
|
-
[0, '10i0'],
|
|
36
|
-
[0, '10i0', { setlen: 'rec2' }],
|
|
37
|
-
['', '7A'],
|
|
38
|
-
['', '1A'],
|
|
39
|
-
];
|
|
40
|
-
|
|
41
|
-
describe('iPgm Class Unit Tests', () => {
|
|
42
|
-
describe('constructor', () => {
|
|
43
|
-
it('creates and returns an instance of iPgm with lib and function set', () => {
|
|
44
|
-
const pgm = new iPgm('QTOCNETSTS');
|
|
45
|
-
expect(pgm).to.be.instanceOf(iPgm);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
describe('toXML', () => {
|
|
50
|
-
it('returns pgm XML', () => {
|
|
51
|
-
const pgm = new iPgm('QTOCNETSTS',
|
|
52
|
-
{
|
|
53
|
-
lib: 'QSYS',
|
|
54
|
-
func: 'QtoRtvTCPA',
|
|
55
|
-
error: 'on',
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
const expectedXML = '<pgm name=\'QTOCNETSTS\' lib=\'QSYS\' func=\'QtoRtvTCPA\' error=\'on\'></pgm>';
|
|
59
|
-
|
|
60
|
-
expect(pgm.toXML()).to.be.a('string').and.to.equal(expectedXML);
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
describe('addParam', () => {
|
|
65
|
-
it('appends param to pgm xml', () => {
|
|
66
|
-
const pgm = new iPgm('QTOCNETSTS',
|
|
67
|
-
{
|
|
68
|
-
lib: 'QSYS',
|
|
69
|
-
func: 'QtoRtvTCPA',
|
|
70
|
-
error: 'fast',
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
pgm.addParam(outBuf, { io: 'out' });
|
|
74
|
-
|
|
75
|
-
let expectedXML = '<pgm name=\'QTOCNETSTS\' lib=\'QSYS\' func=\'QtoRtvTCPA\' error=\'fast\'>'
|
|
76
|
-
+ '<parm io=\'out\'><ds><data type=\'10i0\'>0</data><data type=\'10i0\'>'
|
|
77
|
-
+ '0</data><data type=\'36h\'></data><data type=\'10A\'></data>'
|
|
78
|
-
+ '<data type=\'1A\'></data><data type=\'1A\'></data><data type=\'10i0\'>'
|
|
79
|
-
+ '0</data><data type=\'10i0\'>0</data></ds></parm></pgm>';
|
|
80
|
-
|
|
81
|
-
expect(pgm.toXML()).to.equal(expectedXML);
|
|
82
|
-
|
|
83
|
-
pgm.addParam(66, '10i0');
|
|
84
|
-
|
|
85
|
-
expectedXML = '<pgm name=\'QTOCNETSTS\' lib=\'QSYS\' func=\'QtoRtvTCPA\' error=\'fast\'>'
|
|
86
|
-
+ '<parm io=\'out\'><ds><data type=\'10i0\'>0</data><data type=\'10i0\'>'
|
|
87
|
-
+ '0</data><data type=\'36h\'></data><data type=\'10A\'></data>'
|
|
88
|
-
+ '<data type=\'1A\'></data><data type=\'1A\'></data><data type=\'10i0\'>'
|
|
89
|
-
+ '0</data><data type=\'10i0\'>0</data></ds></parm>'
|
|
90
|
-
+ '<parm><data type=\'10i0\'>66</data></parm></pgm>';
|
|
91
|
-
|
|
92
|
-
expect(pgm.toXML()).to.equal(expectedXML);
|
|
93
|
-
|
|
94
|
-
pgm.addParam(1, '10i0');
|
|
95
|
-
|
|
96
|
-
expectedXML = '<pgm name=\'QTOCNETSTS\' lib=\'QSYS\' func=\'QtoRtvTCPA\' error=\'fast\'>'
|
|
97
|
-
+ '<parm io=\'out\'><ds><data type=\'10i0\'>0</data><data type=\'10i0\'>'
|
|
98
|
-
+ '0</data><data type=\'36h\'></data><data type=\'10A\'></data>'
|
|
99
|
-
+ '<data type=\'1A\'></data><data type=\'1A\'></data><data type=\'10i0\'>'
|
|
100
|
-
+ '0</data><data type=\'10i0\'>0</data></ds></parm>'
|
|
101
|
-
+ '<parm><data type=\'10i0\'>66</data></parm>'
|
|
102
|
-
+ '<parm><data type=\'10i0\'>1</data></parm></pgm>';
|
|
103
|
-
|
|
104
|
-
expect(pgm.toXML()).to.equal(expectedXML);
|
|
105
|
-
|
|
106
|
-
pgm.addParam('QCCSID', '10A');
|
|
107
|
-
|
|
108
|
-
expectedXML = '<pgm name=\'QTOCNETSTS\' lib=\'QSYS\' func=\'QtoRtvTCPA\' error=\'fast\'>'
|
|
109
|
-
+ '<parm io=\'out\'><ds><data type=\'10i0\'>0</data><data type=\'10i0\'>'
|
|
110
|
-
+ '0</data><data type=\'36h\'></data><data type=\'10A\'></data>'
|
|
111
|
-
+ '<data type=\'1A\'></data><data type=\'1A\'></data><data type=\'10i0\'>'
|
|
112
|
-
+ '0</data><data type=\'10i0\'>0</data></ds></parm>'
|
|
113
|
-
+ '<parm><data type=\'10i0\'>66</data></parm>'
|
|
114
|
-
+ '<parm><data type=\'10i0\'>1</data></parm>'
|
|
115
|
-
+ '<parm><data type=\'10A\'>QCCSID</data></parm></pgm>';
|
|
116
|
-
|
|
117
|
-
expect(pgm.toXML()).to.equal(expectedXML);
|
|
118
|
-
|
|
119
|
-
pgm.addParam(errno, { io: 'both', len: 'rec2' });
|
|
120
|
-
|
|
121
|
-
expectedXML = '<pgm name=\'QTOCNETSTS\' lib=\'QSYS\' func=\'QtoRtvTCPA\' error=\'fast\'>'
|
|
122
|
-
+ '<parm io=\'out\'><ds><data type=\'10i0\'>0</data><data type=\'10i0\'>'
|
|
123
|
-
+ '0</data><data type=\'36h\'></data><data type=\'10A\'></data>'
|
|
124
|
-
+ '<data type=\'1A\'></data><data type=\'1A\'></data><data type=\'10i0\'>'
|
|
125
|
-
+ '0</data><data type=\'10i0\'>0</data></ds></parm>'
|
|
126
|
-
+ '<parm><data type=\'10i0\'>66</data></parm>'
|
|
127
|
-
+ '<parm><data type=\'10i0\'>1</data></parm>'
|
|
128
|
-
+ '<parm><data type=\'10A\'>QCCSID</data></parm>'
|
|
129
|
-
+ '<parm io=\'both\'><ds len=\'rec2\'><data type=\'10i0\'>0</data>'
|
|
130
|
-
+ '<data type=\'10i0\' setlen=\'rec2\'>0</data><data type=\'7A\'>'
|
|
131
|
-
+ '</data><data type=\'1A\'></data></ds></parm></pgm>';
|
|
132
|
-
|
|
133
|
-
expect(pgm.toXML()).to.equal(expectedXML);
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it('regular <parm> contains by=\'val\'', () => {
|
|
137
|
-
const pgm = new iPgm('MYPGM', { lib: 'MYLIB', func: 'MY_PROCEDURE' });
|
|
138
|
-
|
|
139
|
-
pgm.addParam('', '1A', { by: 'val' });
|
|
140
|
-
pgm.addReturn('', '2A', { name: 'output' });
|
|
141
|
-
|
|
142
|
-
const lookAtXML = pgm.toXML();
|
|
143
|
-
expect(lookAtXML).to.match(/<parm .*by='val'.*>/);
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
it('data structure <parm> contains by=\'val\'', () => {
|
|
147
|
-
const pgm = new iPgm('MYPGM', { lib: 'MYLIB', func: 'MY_PROCEDURE' });
|
|
148
|
-
|
|
149
|
-
const params = [
|
|
150
|
-
[0, '3s0'],
|
|
151
|
-
[0, '7s0', { name: 'ds_fld2' }],
|
|
152
|
-
];
|
|
153
|
-
|
|
154
|
-
pgm.addParam(params, { name: 'inds', by: 'val' });
|
|
155
|
-
pgm.addReturn('', '2A', { name: 'output' });
|
|
156
|
-
|
|
157
|
-
const lookAtXML = pgm.toXML();
|
|
158
|
-
expect(lookAtXML).to.match(/<parm .*by='val'.*>/);
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
it('regular <parm> contains by=\'val\', with io=\'both\'', () => {
|
|
162
|
-
const pgm = new iPgm('MYPGM', { lib: 'MYLIB', func: 'MY_PROCEDURE' });
|
|
163
|
-
|
|
164
|
-
pgm.addParam('', '1A', { by: 'val', io: 'both' });
|
|
165
|
-
pgm.addReturn('', '2A', { name: 'output' });
|
|
166
|
-
|
|
167
|
-
const lookAtXML = pgm.toXML();
|
|
168
|
-
expect(lookAtXML).to.match(/<parm .*by='val'.*>/);
|
|
169
|
-
expect(lookAtXML).to.match(/<parm .*io='both'.*>/);
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
it('data structure <parm> contains by=\'val\', with io=\'both\'', () => {
|
|
173
|
-
const pgm = new iPgm('MYPGM', { lib: 'MYLIB', func: 'MY_PROCEDURE' });
|
|
174
|
-
|
|
175
|
-
const params = [
|
|
176
|
-
[0, '3s0'],
|
|
177
|
-
[0, '7s0', { name: 'ds_fld2' }],
|
|
178
|
-
];
|
|
179
|
-
|
|
180
|
-
pgm.addParam(params, { name: 'inds', by: 'val', io: 'both' });
|
|
181
|
-
pgm.addReturn('', '2A', { name: 'output' });
|
|
182
|
-
|
|
183
|
-
const lookAtXML = pgm.toXML();
|
|
184
|
-
expect(lookAtXML).to.match(/<parm .*by='val'.*>/);
|
|
185
|
-
expect(lookAtXML).to.match(/<parm .*io='both'.*>/);
|
|
186
|
-
});
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
describe('addReturn', () => {
|
|
191
|
-
it('appends return to pgm xml', () => {
|
|
192
|
-
const pgm = new iPgm('QTOCNETSTS',
|
|
193
|
-
{
|
|
194
|
-
lib: 'QSYS',
|
|
195
|
-
func: 'QtoRtvTCPA',
|
|
196
|
-
error: 'fast',
|
|
197
|
-
});
|
|
198
|
-
|
|
199
|
-
pgm.addReturn('0', '20A');
|
|
200
|
-
|
|
201
|
-
const expectedXML = '<pgm name=\'QTOCNETSTS\' lib=\'QSYS\' func=\'QtoRtvTCPA\' '
|
|
202
|
-
+ 'error=\'fast\'><return><data type=\'20A\'>0</data></return></pgm>';
|
|
203
|
-
|
|
204
|
-
expect(pgm.toXML()).to.equal(expectedXML);
|
|
205
|
-
});
|
|
206
|
-
});
|
|
207
|
-
});
|
|
@@ -1,442 +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 { iSql } = require('../../../lib/itoolkit');
|
|
23
|
-
|
|
24
|
-
describe('iSql Class Unit Tests', () => {
|
|
25
|
-
describe('constructor', () => {
|
|
26
|
-
it('creates returns an instance of iSql', () => {
|
|
27
|
-
const sql = new iSql();
|
|
28
|
-
|
|
29
|
-
expect(sql).to.be.instanceOf(iSql);
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
describe('toXML', () => {
|
|
33
|
-
it('returns current sql XML', () => {
|
|
34
|
-
const sql = new iSql();
|
|
35
|
-
|
|
36
|
-
const expectedXML = '<sql></sql>';
|
|
37
|
-
|
|
38
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
describe('addQuery', () => {
|
|
42
|
-
it('appends query with error is on to sql XML', () => {
|
|
43
|
-
const sql = new iSql();
|
|
44
|
-
|
|
45
|
-
const expectedXML = '<sql><query error=\'on\'>select * from QIWS.QCUSTCDT</query></sql>';
|
|
46
|
-
|
|
47
|
-
sql.addQuery('select * from QIWS.QCUSTCDT', { error: 'on' });
|
|
48
|
-
|
|
49
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
50
|
-
});
|
|
51
|
-
it('appends query with options object to sql XML', () => {
|
|
52
|
-
const sql = new iSql();
|
|
53
|
-
|
|
54
|
-
const expectedXML = '<sql><query error=\'fast\'>select * from QIWS.QCUSTCDT</query></sql>';
|
|
55
|
-
|
|
56
|
-
sql.addQuery('select * from QIWS.QCUSTCDT');
|
|
57
|
-
|
|
58
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
describe('fetch', () => {
|
|
62
|
-
it('appends fetch without options object to sql XML', () => {
|
|
63
|
-
const sql = new iSql();
|
|
64
|
-
|
|
65
|
-
const expectedXML = '<sql><fetch block=\'all\' desc=\'on\' error=\'fast\'></fetch></sql>';
|
|
66
|
-
|
|
67
|
-
sql.fetch();
|
|
68
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
69
|
-
});
|
|
70
|
-
it('appends fetch with block is 10 to sql XML', () => {
|
|
71
|
-
const sql = new iSql();
|
|
72
|
-
|
|
73
|
-
const expectedXML = '<sql><fetch block=\'10\' desc=\'on\' error=\'fast\'></fetch></sql>';
|
|
74
|
-
|
|
75
|
-
sql.fetch({ block: '10' });
|
|
76
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
77
|
-
});
|
|
78
|
-
it('appends fetch with desc is off to sql XML', () => {
|
|
79
|
-
const sql = new iSql();
|
|
80
|
-
|
|
81
|
-
const expectedXML = '<sql><fetch block=\'all\' desc=\'off\' error=\'fast\'></fetch></sql>';
|
|
82
|
-
|
|
83
|
-
sql.fetch({ desc: 'off' });
|
|
84
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
85
|
-
});
|
|
86
|
-
it('appends fetch with error is on to sql XML', () => {
|
|
87
|
-
const sql = new iSql();
|
|
88
|
-
|
|
89
|
-
const expectedXML = '<sql><fetch block=\'all\' desc=\'on\' error=\'on\'></fetch></sql>';
|
|
90
|
-
|
|
91
|
-
sql.fetch({ error: 'on' });
|
|
92
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
describe('commit', () => {
|
|
96
|
-
it('appends commit with action commit to sql XML', () => {
|
|
97
|
-
const sql = new iSql();
|
|
98
|
-
|
|
99
|
-
const expectedXML = '<sql><commit action=\'commit\' error=\'fast\'></commit></sql>';
|
|
100
|
-
|
|
101
|
-
sql.commit({ action: 'commit' });
|
|
102
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
103
|
-
});
|
|
104
|
-
it('appends commit with action rollback to sql XML', () => {
|
|
105
|
-
const sql = new iSql();
|
|
106
|
-
|
|
107
|
-
const expectedXML = '<sql><commit action=\'rollback\' error=\'fast\'></commit></sql>';
|
|
108
|
-
|
|
109
|
-
sql.commit({ action: 'rollback' });
|
|
110
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
111
|
-
});
|
|
112
|
-
it('appends commit with default action to sql XML', () => {
|
|
113
|
-
const sql = new iSql();
|
|
114
|
-
|
|
115
|
-
const expectedXML = '<sql><commit action=\'commit\' error=\'fast\'></commit></sql>';
|
|
116
|
-
|
|
117
|
-
sql.commit();
|
|
118
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
119
|
-
});
|
|
120
|
-
it('appends commit with error is on to sql XML', () => {
|
|
121
|
-
const sql = new iSql();
|
|
122
|
-
|
|
123
|
-
const expectedXML = '<sql><commit action=\'commit\' error=\'on\'></commit></sql>';
|
|
124
|
-
|
|
125
|
-
sql.commit({ action: 'commit', error: 'on' });
|
|
126
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
describe('prepare', () => {
|
|
130
|
-
it('appends prepare to sql XML', () => {
|
|
131
|
-
const sql = new iSql();
|
|
132
|
-
|
|
133
|
-
const expectedXML = '<sql><prepare error=\'fast\'>SELECT * FROM QIWS.QCUSTCDT WHERE BALDUE > ?</prepare></sql>';
|
|
134
|
-
|
|
135
|
-
sql.prepare('SELECT * FROM QIWS.QCUSTCDT WHERE BALDUE > ?');
|
|
136
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
137
|
-
});
|
|
138
|
-
it('appends prepare with error on to sql XML', () => {
|
|
139
|
-
const sql = new iSql();
|
|
140
|
-
|
|
141
|
-
const expectedXML = '<sql><prepare error=\'on\'>SELECT * FROM QIWS.QCUSTCDT WHERE BALDUE > ?</prepare></sql>';
|
|
142
|
-
|
|
143
|
-
sql.prepare('SELECT * FROM QIWS.QCUSTCDT WHERE BALDUE > ?', { error: 'on' });
|
|
144
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
describe('execute', () => {
|
|
149
|
-
it('appends execute with parameters to sql XML', () => {
|
|
150
|
-
const sql = new iSql();
|
|
151
|
-
|
|
152
|
-
const expectedXML = '<sql><execute error=\'fast\'><parm io=\'in\'>30</parm></execute></sql>';
|
|
153
|
-
|
|
154
|
-
sql.execute([[30, 'in']]);
|
|
155
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
156
|
-
});
|
|
157
|
-
it('appends execute with parameters and error on to sql XML', () => {
|
|
158
|
-
const sql = new iSql();
|
|
159
|
-
|
|
160
|
-
const expectedXML = '<sql><execute error=\'on\'><parm io=\'in\'>30</parm></execute></sql>';
|
|
161
|
-
|
|
162
|
-
sql.execute([[30, 'in']], { error: 'on' });
|
|
163
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
164
|
-
});
|
|
165
|
-
it('appends execute without parameters to sql XML', () => {
|
|
166
|
-
const sql = new iSql();
|
|
167
|
-
|
|
168
|
-
const expectedXML = '<sql><execute error=\'fast\'></execute></sql>';
|
|
169
|
-
|
|
170
|
-
sql.execute();
|
|
171
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
172
|
-
});
|
|
173
|
-
it('appends execute without parameters and error on to sql XML', () => {
|
|
174
|
-
const sql = new iSql();
|
|
175
|
-
|
|
176
|
-
const expectedXML = '<sql><execute error=\'on\'></execute></sql>';
|
|
177
|
-
|
|
178
|
-
sql.execute(null, { error: 'on' });
|
|
179
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
describe('tables', () => {
|
|
183
|
-
it('appends tables to sql XML', () => {
|
|
184
|
-
const sql = new iSql();
|
|
185
|
-
|
|
186
|
-
const expectedXML = '<sql><tables error=\'fast\'><parm></parm><parm>QIWS</parm><parm></parm><parm></parm></tables></sql>';
|
|
187
|
-
// catalog, schema, table, table type
|
|
188
|
-
sql.tables(['', 'QIWS', '', '']);
|
|
189
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
190
|
-
});
|
|
191
|
-
it('appends tables with error on to sql XML', () => {
|
|
192
|
-
const sql = new iSql();
|
|
193
|
-
|
|
194
|
-
const expectedXML = '<sql><tables error=\'on\'><parm></parm><parm>QIWS</parm><parm></parm><parm></parm></tables></sql>';
|
|
195
|
-
// catalog, schema, table, table type
|
|
196
|
-
sql.tables(['', 'QIWS', '', ''], { error: 'on' });
|
|
197
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
describe('tablePriv', () => {
|
|
201
|
-
it('appends tablepriv to sql XML', () => {
|
|
202
|
-
const sql = new iSql();
|
|
203
|
-
|
|
204
|
-
const expectedXML = '<sql><tablepriv error=\'fast\'><parm></parm><parm>QIWS</parm><parm>QCUSTCDT</parm></tablepriv></sql>';
|
|
205
|
-
// catalog, schema, table
|
|
206
|
-
sql.tablePriv(['', 'QIWS', 'QCUSTCDT']);
|
|
207
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
208
|
-
});
|
|
209
|
-
it('appends tablepriv with error on to sql XML', () => {
|
|
210
|
-
const sql = new iSql();
|
|
211
|
-
|
|
212
|
-
const expectedXML = '<sql><tablepriv error=\'on\'><parm></parm><parm>QIWS</parm><parm>QCUSTCDT</parm></tablepriv></sql>';
|
|
213
|
-
// catalog, schema, table
|
|
214
|
-
sql.tablePriv(['', 'QIWS', 'QCUSTCDT'], { error: 'on' });
|
|
215
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
describe('columns', () => {
|
|
219
|
-
it('appends columns to sql XML', () => {
|
|
220
|
-
const sql = new iSql();
|
|
221
|
-
|
|
222
|
-
const expectedXML = '<sql><columns error=\'fast\'><parm></parm><parm>QIWS</parm><parm>QCUSTCDT</parm><parm></parm></columns></sql>';
|
|
223
|
-
// catalog, schema, table, column
|
|
224
|
-
sql.columns(['', 'QIWS', 'QCUSTCDT', '']);
|
|
225
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
226
|
-
});
|
|
227
|
-
it('appends columns with error on to sql XML', () => {
|
|
228
|
-
const sql = new iSql();
|
|
229
|
-
|
|
230
|
-
const expectedXML = '<sql><columns error=\'on\'><parm></parm><parm>QIWS</parm><parm>QCUSTCDT</parm><parm></parm></columns></sql>';
|
|
231
|
-
// catalog, schema, table, column
|
|
232
|
-
sql.columns(['', 'QIWS', 'QCUSTCDT', ''], { error: 'on' });
|
|
233
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
234
|
-
});
|
|
235
|
-
});
|
|
236
|
-
describe('columnPriv', () => {
|
|
237
|
-
it('appends columnpriv to sql XML', () => {
|
|
238
|
-
const sql = new iSql();
|
|
239
|
-
|
|
240
|
-
const expectedXML = '<sql><columnpriv error=\'fast\'><parm></parm><parm>QIWS</parm><parm>QCUSTCDT</parm><parm></parm></columnpriv></sql>';
|
|
241
|
-
// catalog, schema, table, column
|
|
242
|
-
sql.columnPriv(['', 'QIWS', 'QCUSTCDT', '']);
|
|
243
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
244
|
-
});
|
|
245
|
-
it('appends columnpriv with error on to sql XML', () => {
|
|
246
|
-
const sql = new iSql();
|
|
247
|
-
|
|
248
|
-
const expectedXML = '<sql><columnpriv error=\'on\'><parm></parm><parm>QIWS</parm><parm>QCUSTCDT</parm><parm></parm></columnpriv></sql>';
|
|
249
|
-
// catalog, schema, table, column
|
|
250
|
-
sql.columnPriv(['', 'QIWS', 'QCUSTCDT', ''], { error: 'on' });
|
|
251
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
252
|
-
});
|
|
253
|
-
});
|
|
254
|
-
describe('procedures', () => {
|
|
255
|
-
it('appends procedures to sql XML', () => {
|
|
256
|
-
const sql = new iSql();
|
|
257
|
-
|
|
258
|
-
const expectedXML = '<sql><procedures error=\'fast\'><parm></parm><parm>QSYS2</parm><parm>TCPIP_INFO</parm></procedures></sql>';
|
|
259
|
-
// catalog, schema, procedure
|
|
260
|
-
sql.procedures(['', 'QSYS2', 'TCPIP_INFO']);
|
|
261
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
262
|
-
});
|
|
263
|
-
it('appends procedures with error on to sql XML', () => {
|
|
264
|
-
const sql = new iSql();
|
|
265
|
-
|
|
266
|
-
const expectedXML = '<sql><procedures error=\'on\'><parm></parm><parm>QSYS2</parm><parm>TCPIP_INFO</parm></procedures></sql>';
|
|
267
|
-
// catalog, schema, procedure
|
|
268
|
-
sql.procedures(['', 'QSYS2', 'TCPIP_INFO'], { error: 'on' });
|
|
269
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
270
|
-
});
|
|
271
|
-
});
|
|
272
|
-
describe('pColumns', () => {
|
|
273
|
-
it('appends pColumns to sql XML', () => {
|
|
274
|
-
// procedure columns:
|
|
275
|
-
const sql = new iSql();
|
|
276
|
-
|
|
277
|
-
const expectedXML = '<sql><pcolumns error=\'fast\'><parm></parm><parm>QSYS2</parm><parm>QCMDEXC</parm><parm>COMMAND</parm></pcolumns></sql>';
|
|
278
|
-
// catalog, schema, procedure, column
|
|
279
|
-
sql.pColumns(['', 'QSYS2', 'QCMDEXC', 'COMMAND']);
|
|
280
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
281
|
-
});
|
|
282
|
-
it('appends pColumns with error on to sql XML', () => {
|
|
283
|
-
// procedure columns:
|
|
284
|
-
const sql = new iSql();
|
|
285
|
-
|
|
286
|
-
const expectedXML = '<sql><pcolumns error=\'on\'><parm></parm><parm>QSYS2</parm><parm>QCMDEXC</parm><parm>COMMAND</parm></pcolumns></sql>';
|
|
287
|
-
// catalog, schema, procedure, column
|
|
288
|
-
sql.pColumns(['', 'QSYS2', 'QCMDEXC', 'COMMAND'], { error: 'on' });
|
|
289
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
290
|
-
});
|
|
291
|
-
});
|
|
292
|
-
describe('primaryKeys', () => {
|
|
293
|
-
it('appends primarykeys to sql XML', () => {
|
|
294
|
-
const sql = new iSql();
|
|
295
|
-
|
|
296
|
-
const expectedXML = '<sql><primarykeys error=\'fast\'><parm></parm><parm>QUSRSYS</parm><parm>QASZRAIRX</parm></primarykeys></sql>';
|
|
297
|
-
// catalog, schema, table
|
|
298
|
-
sql.primaryKeys(['', 'QUSRSYS', 'QASZRAIRX']);
|
|
299
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
300
|
-
});
|
|
301
|
-
it('appends primarykeys with error on to sql XML', () => {
|
|
302
|
-
const sql = new iSql();
|
|
303
|
-
|
|
304
|
-
const expectedXML = '<sql><primarykeys error=\'on\'><parm></parm><parm>QUSRSYS</parm><parm>QASZRAIRX</parm></primarykeys></sql>';
|
|
305
|
-
// catalog, schema, table
|
|
306
|
-
sql.primaryKeys(['', 'QUSRSYS', 'QASZRAIRX'], { error: 'on' });
|
|
307
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
308
|
-
});
|
|
309
|
-
});
|
|
310
|
-
describe('foreignKeys', () => {
|
|
311
|
-
it('appends foreignkeys to sql XML', () => {
|
|
312
|
-
const sql = new iSql();
|
|
313
|
-
|
|
314
|
-
const expectedXML = '<sql><foreignkeys error=\'fast\'><parm></parm><parm>QUSRSYS</parm><parm>QASZRAIRC</parm><parm></parm><parm>QUSRSYS</parm><parm>QASZRAIRX</parm></foreignkeys></sql>';
|
|
315
|
-
|
|
316
|
-
// pk: catalog, schema, table
|
|
317
|
-
// fk: catalog, schema, table
|
|
318
|
-
sql.foreignKeys(['', 'QUSRSYS', 'QASZRAIRC', '', 'QUSRSYS', 'QASZRAIRX']);
|
|
319
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
320
|
-
});
|
|
321
|
-
it('appends foreignkeys with error on to sql XML', () => {
|
|
322
|
-
const sql = new iSql();
|
|
323
|
-
|
|
324
|
-
const expectedXML = '<sql><foreignkeys error=\'on\'><parm></parm><parm>QUSRSYS</parm><parm>QASZRAIRC</parm><parm></parm><parm>QUSRSYS</parm><parm>QASZRAIRX</parm></foreignkeys></sql>';
|
|
325
|
-
|
|
326
|
-
// pk: catalog, schema, table
|
|
327
|
-
// fk: catalog, schema, table
|
|
328
|
-
sql.foreignKeys(['', 'QUSRSYS', 'QASZRAIRC', '', 'QUSRSYS', 'QASZRAIRX'], { error: 'on' });
|
|
329
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
330
|
-
});
|
|
331
|
-
});
|
|
332
|
-
describe('statistics', () => {
|
|
333
|
-
it('appends statistics to sql XML', () => {
|
|
334
|
-
const sql = new iSql();
|
|
335
|
-
|
|
336
|
-
const expectedXML = '<sql><statistics error=\'fast\'><parm></parm><parm>QIWS</parm><parm>QCUSTCDT</parm><parm>all</parm></statistics></sql>';
|
|
337
|
-
// catalog, schema, table, all | unique
|
|
338
|
-
sql.statistics(['', 'QIWS', 'QCUSTCDT', 'all']);
|
|
339
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
340
|
-
});
|
|
341
|
-
it('appends statistics with error on to sql XML', () => {
|
|
342
|
-
const sql = new iSql();
|
|
343
|
-
|
|
344
|
-
const expectedXML = '<sql><statistics error=\'on\'><parm></parm><parm>QIWS</parm><parm>QCUSTCDT</parm><parm>all</parm></statistics></sql>';
|
|
345
|
-
// catalog, schema, table, all | unique
|
|
346
|
-
sql.statistics(['', 'QIWS', 'QCUSTCDT', 'all'], { error: 'on' });
|
|
347
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
348
|
-
});
|
|
349
|
-
});
|
|
350
|
-
describe('special', () => {
|
|
351
|
-
it('appends special to sql XML', () => {
|
|
352
|
-
const sql = new iSql();
|
|
353
|
-
|
|
354
|
-
const expectedXML = '<sql><special error=\'fast\'><parm></parm><parm>QIWS</parm><parm>QCUSTCDT</parm><parm>row</parm><parm>no</parm></special></sql>';
|
|
355
|
-
// catalog, schema, table, row | transaction | session, no | unique
|
|
356
|
-
sql.special(['', 'QIWS', 'QCUSTCDT', 'row', 'no']);
|
|
357
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
358
|
-
});
|
|
359
|
-
it('appends special with error on to sql XML', () => {
|
|
360
|
-
const sql = new iSql();
|
|
361
|
-
|
|
362
|
-
const expectedXML = '<sql><special error=\'on\'><parm></parm><parm>QIWS</parm><parm>QCUSTCDT</parm><parm>row</parm><parm>no</parm></special></sql>';
|
|
363
|
-
// catalog, schema, table, row | transaction | session, no | unique
|
|
364
|
-
sql.special(['', 'QIWS', 'QCUSTCDT', 'row', 'no'], { error: 'on' });
|
|
365
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
366
|
-
});
|
|
367
|
-
});
|
|
368
|
-
describe('count', () => {
|
|
369
|
-
it('appends count to sql XML', () => {
|
|
370
|
-
const sql = new iSql();
|
|
371
|
-
|
|
372
|
-
const expectedXML = '<sql><count desc=\'both\' error=\'fast\'></count></sql>';
|
|
373
|
-
sql.count({ desc: 'both' });
|
|
374
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
375
|
-
});
|
|
376
|
-
it('appends count without options object to sql XML', () => {
|
|
377
|
-
const sql = new iSql();
|
|
378
|
-
|
|
379
|
-
const expectedXML = '<sql><count desc=\'both\' error=\'fast\'></count></sql>';
|
|
380
|
-
sql.count();
|
|
381
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
382
|
-
});
|
|
383
|
-
it('appends count with error on to sql XML', () => {
|
|
384
|
-
const sql = new iSql();
|
|
385
|
-
|
|
386
|
-
const expectedXML = '<sql><count desc=\'both\' error=\'on\'></count></sql>';
|
|
387
|
-
sql.count({ error: 'on' });
|
|
388
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
389
|
-
});
|
|
390
|
-
});
|
|
391
|
-
describe('rowCount', () => {
|
|
392
|
-
it('appends rowcount to sql XML', () => {
|
|
393
|
-
const sql = new iSql();
|
|
394
|
-
|
|
395
|
-
const expectedXML = '<sql><rowcount error=\'fast\'></rowcount></sql>';
|
|
396
|
-
sql.rowCount();
|
|
397
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
398
|
-
});
|
|
399
|
-
it('appends rowcount with error on to sql XML', () => {
|
|
400
|
-
const sql = new iSql();
|
|
401
|
-
|
|
402
|
-
const expectedXML = '<sql><rowcount error=\'on\'></rowcount></sql>';
|
|
403
|
-
sql.rowCount({ error: 'on' });
|
|
404
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
405
|
-
});
|
|
406
|
-
});
|
|
407
|
-
describe('free', () => {
|
|
408
|
-
it('appends free to sql XML', () => {
|
|
409
|
-
const sql = new iSql();
|
|
410
|
-
|
|
411
|
-
const expectedXML = '<sql><free></free></sql>';
|
|
412
|
-
sql.free();
|
|
413
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
414
|
-
});
|
|
415
|
-
});
|
|
416
|
-
describe('describe', () => {
|
|
417
|
-
it('appends describe to sql XML', () => {
|
|
418
|
-
const sql = new iSql();
|
|
419
|
-
|
|
420
|
-
const expectedXML = '<sql><describe desc=\'both\' error=\'fast\'></describe></sql>';
|
|
421
|
-
|
|
422
|
-
sql.describe({ desc: 'both' });
|
|
423
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
424
|
-
});
|
|
425
|
-
it('appends describe without options object to sql XML', () => {
|
|
426
|
-
const sql = new iSql();
|
|
427
|
-
|
|
428
|
-
const expectedXML = '<sql><describe desc=\'both\' error=\'fast\'></describe></sql>';
|
|
429
|
-
|
|
430
|
-
sql.describe();
|
|
431
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
432
|
-
});
|
|
433
|
-
it('appends describe with error on to sql XML', () => {
|
|
434
|
-
const sql = new iSql();
|
|
435
|
-
|
|
436
|
-
const expectedXML = '<sql><describe desc=\'both\' error=\'on\'></describe></sql>';
|
|
437
|
-
|
|
438
|
-
sql.describe({ error: 'on' });
|
|
439
|
-
expect(sql.toXML()).to.equal(expectedXML);
|
|
440
|
-
});
|
|
441
|
-
});
|
|
442
|
-
});
|