Skip to content

test: Use XMLValidator #403

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
18 changes: 13 additions & 5 deletions test/functional/CommandCallFunctional.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: MIT

const { expect } = require('chai');
const { XMLParser } = require('fast-xml-parser');
const { XMLParser, XMLValidator } = require('fast-xml-parser');
const { CommandCall, Connection, ProgramCall } = require('../../lib/itoolkit');
const { config, printConfig } = require('./config');
const { isQSHSupported } = require('./checkVersion');
Expand All @@ -18,9 +18,12 @@ describe('CommandCall Functional Tests', function () {
connection.add(new CommandCall({ command: 'RTVJOBA USRLIBL(?) SYSLIBL(?)', type: 'cl' }));
connection.run((error, xmlOut) => {
expect(error).to.equal(null);
const validate = XMLValidator.validate(xmlOut, {
allowBooleanAttributes: true,
});
expect(validate).to.equal(true);
const parser = new XMLParser();
const result = parser.parse(xmlOut);
expect(Object.keys(result).length).gt(0);
expect(result.myscript.cmd.success).to.include('+++ success RTVJOBA USRLIBL(?) SYSLIBL(?)');
done();
});
Expand All @@ -35,10 +38,12 @@ describe('CommandCall Functional Tests', function () {
expect(error).to.equal(null);
// xs does not return success property for sh or qsh command calls
// but on error sh or qsh node will not have any inner data

const validate = XMLValidator.validate(xmlOut, {
allowBooleanAttributes: true,
});
expect(validate).to.equal(true);
const parser = new XMLParser();
const result = parser.parse(xmlOut);
expect(Object.keys(result).length).gt(0);
expect(result.myscript.sh).to.match(/(System\sStatus\sInformation)/);
done();
});
Expand All @@ -55,9 +60,12 @@ describe('CommandCall Functional Tests', function () {
// xs does not return success property for sh or qsh command calls
// but on error sh or qsh node will not have any inner data

const validate = XMLValidator.validate(xmlOut, {
allowBooleanAttributes: true,
});
expect(validate).to.equal(true);
const parser = new XMLParser();
const result = parser.parse(xmlOut);
expect(Object.keys(result).length).gt(0);
const { version } = result.myscript.pgm;
const match = version.match(/\d\.\d\.\d/);

Expand Down
12 changes: 9 additions & 3 deletions test/functional/ProgramCallFunctional.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: MIT

const { expect } = require('chai');
const { XMLParser } = require('fast-xml-parser');
const { XMLParser, XMLValidator } = require('fast-xml-parser');
const { ProgramCall, Connection } = require('../../lib/itoolkit');
const { config, printConfig } = require('./config');

Expand Down Expand Up @@ -58,9 +58,12 @@ describe('ProgramCall Functional Tests', function () {
connection.run((error, xmlOut) => {
expect(error).to.equal(null);

const validate = XMLValidator.validate(xmlOut, {
allowBooleanAttributes: true,
});
expect(validate).to.equal(true);
const parser = new XMLParser();
const result = parser.parse(xmlOut);
expect(Object.keys(result).length).gt(0);
expect(result.myscript.pgm.success).to.include('+++ success QSYS QWCRSVAL');
done();
});
Expand All @@ -84,9 +87,12 @@ describe('ProgramCall Functional Tests', function () {
connection.add(program);
connection.run((error, xmlOut) => {
expect(error).to.equal(null);
const validate = XMLValidator.validate(xmlOut, {
allowBooleanAttributes: true,
});
expect(validate).to.equal(true);
const parser = new XMLParser();
const result = parser.parse(xmlOut);
expect(Object.keys(result).length).gt(0);
expect(result.myscript.pgm.success).to.include('+++ success');
expect(result.myscript.pgm.return.data).to.equal('my name is Gill');
done();
Expand Down
17 changes: 13 additions & 4 deletions test/functional/deprecated/commandsFunctional.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/* eslint-disable new-cap */

const { expect } = require('chai');
const { XMLParser } = require('fast-xml-parser');
const { XMLParser, XMLValidator } = require('fast-xml-parser');
const {
iCmd, iSh, iQsh, iConn, iPgm,
} = require('../../../lib/itoolkit');
Expand Down Expand Up @@ -41,9 +41,12 @@ describe('iSh, iCmd, iQsh, Functional Tests', function () {
const connection = new iConn(database, username, password, restOptions);
connection.add(iCmd('RTVJOBA USRLIBL(?) SYSLIBL(?)'));
connection.run((xmlOut) => {
const validate = XMLValidator.validate(xmlOut, {
allowBooleanAttributes: true,
});
expect(validate).to.equal(true);
const parser = new XMLParser();
const result = parser.parse(xmlOut);
expect(Object.keys(result).length).gt(0);
expect(result.myscript.cmd.success).to.include('+++ success RTVJOBA USRLIBL(?) SYSLIBL(?)');
done();
});
Expand All @@ -57,9 +60,12 @@ describe('iSh, iCmd, iQsh, Functional Tests', function () {
connection.run((xmlOut) => {
// xs does not return success property for sh or qsh command calls
// but on error sh or qsh node will not have any inner data
const validate = XMLValidator.validate(xmlOut, {
allowBooleanAttributes: true,
});
expect(validate).to.equal(true);
const parser = new XMLParser();
const result = parser.parse(xmlOut);
expect(Object.keys(result).length).gt(0);
expect(result.myscript.sh).to.match(/(System\sStatus\sInformation)/);
done();
});
Expand All @@ -74,9 +80,12 @@ describe('iSh, iCmd, iQsh, Functional Tests', function () {
connection.run((xmlOut) => {
// xs does not return success property for sh or qsh command calls
// but on error sh or qsh node will not have any inner data
const validate = XMLValidator.validate(xmlOut, {
allowBooleanAttributes: true,
});
expect(validate).to.equal(true);
const parser = new XMLParser();
const result = parser.parse(xmlOut);
expect(Object.keys(result).length).gt(0);
const { version } = result.myscript.pgm;
const match = version.match(/\d\.\d\.\d/);

Expand Down
12 changes: 9 additions & 3 deletions test/functional/deprecated/iPgmFunctional.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/* eslint-disable new-cap */

const { expect } = require('chai');
const { XMLParser } = require('fast-xml-parser');
const { XMLParser, XMLValidator } = require('fast-xml-parser');
const { iPgm, iConn } = require('../../../lib/itoolkit');
const { config, printConfig } = require('../config');

Expand Down Expand Up @@ -56,9 +56,12 @@ describe('iPgm Functional Tests', function () {
program.addParam(this.errno, { io: 'both', len: 'rec2' });
connection.add(program);
connection.run((xmlOut) => {
const validate = XMLValidator.validate(xmlOut, {
allowBooleanAttributes: true,
});
expect(validate).to.equal(true);
const parser = new XMLParser();
const result = parser.parse(xmlOut);
expect(Object.keys(result).length).gt(0);
expect(result.myscript.pgm.success).to.include('+++ success QSYS QWCRSVAL');
done();
});
Expand All @@ -78,9 +81,12 @@ describe('iPgm Functional Tests', function () {
program.addReturn('0', '20A', { varying: '4', name: testValue });
connection.add(program);
connection.run((xmlOut) => {
const validate = XMLValidator.validate(xmlOut, {
allowBooleanAttributes: true,
});
expect(validate).to.equal(true);
const parser = new XMLParser();
const result = parser.parse(xmlOut);
expect(Object.keys(result).length).gt(0);
expect(result.myscript.pgm.success).to.include('+++ success');
expect(result.myscript.pgm.return.data).to.equal('my name is Gill');
done();
Expand Down
Loading
Loading