Skip to content

test: Pass object to addParam in ProgramCallFunctional.js #195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
125 changes: 76 additions & 49 deletions test/functional/ProgramCallFunctional.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,29 +52,43 @@ describe('ProgramCall Functional Tests', () => {

const program = new ProgramCall('QWCRSVAL', { lib: 'QSYS' });

const outBuf = [
[0, '10i0'],
[0, '10i0'],
['', '36h'],
['', '10A'],
['', '1A'],
['', '1A'],
[0, '10i0'],
[0, '10i0'],
];

const errno = [
[0, '10i0'],
[0, '10i0', { setlen: 'rec2' }],
['', '7A'],
['', '1A'],
];

program.addParam(outBuf, { io: 'out' });
program.addParam(66, '10i0');
program.addParam(1, '10i0');
program.addParam('QCCSID', '10A');
program.addParam(errno, { io: 'both', len: 'rec2' });
const outBuf = {
type: 'ds',
io: 'out',
fields: [
{ type: '10i0', value: 0 },
{ type: '10i0', value: 0 },
{ type: '36h', value: '' },
{ type: '10A', value: '' },
{ type: '1A', value: '' },
{ type: '1A', value: '' },
{ type: '10i0', value: 0 },
{ type: '10i0', value: 0 },
],
};

const errno = {
type: 'ds',
io: 'both',
len: 'rec2',
fields: [
{
name: 'bytes_provided',
type: '10i0',
value: 0,
setlen: 'rec2',
},
{ name: 'bytes_available', type: '10i0', value: 0 },
{ name: 'msgid', type: '7A', value: '' },
{ type: '1A', value: '' },
],
};

program.addParam(outBuf);
program.addParam({ type: '10i0', value: 66 });
program.addParam({ type: '10i0', value: 1 });
program.addParam({ type: '10A', value: 'QCCSID' });
program.addParam(errno);
connection.add(program);
connection.run((error, xmlOut) => {
expect(error).to.equal(null);
Expand All @@ -96,31 +110,44 @@ describe('ProgramCall Functional Tests', () => {

const program = new ProgramCall('QWCRSVAL', { lib: 'QSYS' });

const outBuf = [
[0, '10i0'],
[0, '10i0'],
['', '36h'],
['', '10A'],
['', '1A'],
['', '1A'],
[0, '10i0'],
[0, '10i0'],
];

const errno = [
[0, '10i0'],
[0, '10i0', { setlen: 'rec2' }],
['', '7A'],
['', '1A'],
];

program.addParam(outBuf, { io: 'out' });
program.addParam(66, '10i0');
program.addParam(1, '10i0');
program.addParam('QCCSID', '10A');
const paramValue = 'errno';

program.addParam(errno, { io: 'both', len: 'rec2', name: paramValue });
const outBuf = {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second test in ProgramCallFunctional.js Does not seem useful.
Its the exact same test as the first the only difference it adds name field for errno DS.

We should remove it and add other useful ProgramCall functional tests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I think the reason the name was originally in a variable was to test that it comes back, but it never did. Probably makes sense to just remove.

type: 'ds',
io: 'out',
fields: [
{ type: '10i0', value: 0 },
{ type: '10i0', value: 0 },
{ type: '36h', value: '' },
{ type: '10A', value: '' },
{ type: '1A', value: '' },
{ type: '1A', value: '' },
{ type: '10i0', value: 0 },
{ type: '10i0', value: 0 },
],
};

const errno = {
name: 'errno',
type: 'ds',
io: 'both',
len: 'rec2',
fields: [
{
name: 'bytes_provided',
type: '10i0',
value: 0,
setlen: 'rec2',
},
{ name: 'bytes_available', type: '10i0', value: 0 },
{ name: 'msgid', type: '7A', value: '' },
{ type: '1A', value: '' },
],
};

program.addParam(outBuf);
program.addParam({ type: '10i0', value: 66 });
program.addParam({ type: '10i0', value: 1 });
program.addParam({ type: '10A', value: 'QCCSID' });
program.addParam(errno);
connection.add(program);
connection.run((error, xmlOut) => {
expect(error).to.equal(null);
Expand All @@ -143,7 +170,7 @@ describe('ProgramCall Functional Tests', () => {

const program = new ProgramCall('ZZSRV6', { lib: 'XMLSERVICE', func: 'ZZVARY4' });

program.addParam('Gill', '10A', { varying: '4' });
program.addParam({ type: '10A', varying: '4', value: 'Gill' });
const testValue = 'NEW_NAME';
program.addReturn('0', '20A', { varying: '4', name: testValue });
connection.add(program);
Expand Down