Skip to content

test: Mute deprecation warnings #293

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 2 commits 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
10 changes: 10 additions & 0 deletions test/functional/deprecated/commandsFunctional.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ if (config.transport === 'rest') {
describe('iSh, iCmd, iQsh, Functional Tests', function () {
before(function () {
printConfig();
process.on('deprecation', function () {
// capture depreacation warnings but no-op
// test/unit/commandsUnit.js already ensures deprecations are emited
});
});

after(function () {
process.removeAllListeners('deprecation', function () {
// no-op
});
});

describe('iCmd()', function () {
Expand Down
24 changes: 24 additions & 0 deletions test/functional/deprecated/iDataQueueFunctional.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,39 @@ if (config.transport === 'rest') {

const lib = 'NODETKTEST'; const dqName = 'TESTQ';

let deprecation = null;
function deprecationHandler(dep) {
deprecation = dep;
}

function getDeprecation() {
const temp = deprecation;
deprecation = null;
return temp;
Comment on lines +53 to +55
Copy link
Member

Choose a reason for hiding this comment

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

Do we have to worry about race conditions here? Can mocha run tests simultaneously?

Copy link
Member Author

@abmusse abmusse Oct 22, 2020

Choose a reason for hiding this comment

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

By default mocha runs test serially. So in step 12 it describes the flow of execution:
image

So I don't think there would be issue of tests running simultaneously unless we were using parallel mode

}

describe('iDataQueue Functional Tests', function () {
before('check if data queue exists for tests', function (done) {
printConfig();
process.on('deprecation', deprecationHandler);
checkObjectExists(config, dqName, '*DTAQ', (error) => {
if (error) { throw error; }
done();
});
});

after(function () {
process.removeAllListeners('deprecation', deprecationHandler);
});

describe('constructor', function () {
it('creates and returns an instance of iDataQueue', function () {
const connection = new iConn(database, config.user, password);

const dq = new iDataQueue(connection);
expect(dq).to.be.instanceOf(iDataQueue);
expect(getDeprecation().message).to
.equal("As of v1.0, class 'iDataQueue' is deprecated and will be removed at a later time.");
});
});

Expand All @@ -70,6 +88,8 @@ describe('iDataQueue Functional Tests', function () {

dq.sendToDataQueue(dqName, lib, 'Hello from DQ!', (output) => {
expect(output).to.equal(true);
expect(getDeprecation().message).to
.equal("As of v1.0, 'iDataQueue.sendToDataQueue()' is deprecated and will be removed at a later time.");
done();
});
});
Expand All @@ -83,6 +103,8 @@ describe('iDataQueue Functional Tests', function () {

dq.receiveFromDataQueue(dqName, lib, 100, (output) => {
expect(output).to.be.a('string').and.to.equal('Hello from DQ!');
expect(getDeprecation().message).to
.equal("As of v1.0, 'iDataQueue.receiveFromDataQueue()' is deprecated and will be removed at a later time.");
done();
});
});
Expand All @@ -96,6 +118,8 @@ describe('iDataQueue Functional Tests', function () {

dq.clearDataQueue(dqName, lib, (output) => {
expect(output).to.equal(true);
expect(getDeprecation().message).to
.equal("As of v1.0, 'iDataQueue.clearDataQueue()' is deprecated and will be removed at a later time.");
done();
});
});
Expand Down
22 changes: 22 additions & 0 deletions test/functional/deprecated/iNetworkFunctional.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,25 @@ if (config.transport === 'rest') {
};
}

let deprecation = null;
function deprecationHandler(dep) {
deprecation = dep;
}

function getDeprecation() {
const temp = deprecation;
deprecation = null;
return temp;
}

describe('iNetwork Functional Tests', function () {
before(function () {
printConfig();
process.on('deprecation', deprecationHandler);
});

after(function () {
process.removeAllListeners('deprecation', deprecationHandler);
});

describe('constructor', function () {
Expand All @@ -53,6 +69,8 @@ describe('iNetwork Functional Tests', function () {
const net = new iNetwork(connection);

expect(net).to.be.instanceOf(iNetwork);
expect(getDeprecation().message).to
.equal("As of v1.0, class 'iNetwork' is deprecated and will be removed at a later time.");
});
});

Expand All @@ -63,6 +81,8 @@ describe('iNetwork Functional Tests', function () {
const net = new iNetwork(connection);

net.getTCPIPAttr((output) => {
expect(getDeprecation().message).to
.equal("As of v1.0, 'iNetwork.getTCPIPAttr()' is deprecated and will be removed at a later time.");
expect(output).to.be.an('Object');
expect(output).to.have.a.property('TCP/IPv4_stack_status');
expect(output).to.have.a.property('How_long_active');
Expand Down Expand Up @@ -105,6 +125,8 @@ describe('iNetwork Functional Tests', function () {
const net = new iNetwork(connection);

net.getNetInterfaceData('127.0.0.1', (output) => {
expect(getDeprecation().message).to
.equal("As of v1.0, 'iNetwork.getNetInterfaceData()' is deprecated and will be removed at a later time.");
expect(output).to.be.an('Object');
expect(output).to.have.a.property('Internet_address');
expect(output).to.have.a.property('Internet_address_binary');
Expand Down
32 changes: 32 additions & 0 deletions test/functional/deprecated/iObjFunctional.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,25 @@ if (config.transport === 'rest') {
};
}

let deprecation = null;
function deprecationHandler(dep) {
deprecation = dep;
}

function getDeprecation() {
const temp = deprecation;
deprecation = null;
return temp;
}

describe('iObj Functional Tests', function () {
before(function () {
printConfig();
process.on('deprecation', deprecationHandler);
});

after(function () {
process.removeAllListeners('deprecation', deprecationHandler);
});

describe('constructor', function () {
Expand All @@ -53,6 +69,8 @@ describe('iObj Functional Tests', function () {
const obj = new iObj(connection);

expect(obj).to.be.instanceOf(iObj);
expect(getDeprecation().message).to
.equal("As of v1.0, class 'iObj' is deprecated and will be removed at a later time.");
});
});

Expand All @@ -63,6 +81,8 @@ describe('iObj Functional Tests', function () {
const obj = new iObj(connection);

obj.retrUsrAuth('*PUBLIC', '*PGM', 'XMLCGI', 'QXMLSERV', (output) => {
expect(getDeprecation().message).to
.equal("As of v1.0, 'iObj.retrUsrAuth()' is deprecated and will be removed at a later time.");
expect(output).to.be.an('Object');
expect(output).to.have.a.property('Object_authority_/_Data_authority');
expect(output).to.have.a.property('Authorization_list_management');
Expand Down Expand Up @@ -107,6 +127,8 @@ describe('iObj Functional Tests', function () {
const obj = new iObj(connection);

obj.retrCmdInfo('CRTLIB', '*LIBL', (output) => {
expect(getDeprecation().message).to
.equal("As of v1.0, 'iObj.retrCmdInfo()' is deprecated and will be removed at a later time.");
expect(output).to.be.an('Object');
expect(output).to.have.a.property('Command_name');
expect(output).to.have.a.property('Command_library_name');
Expand Down Expand Up @@ -159,6 +181,8 @@ describe('iObj Functional Tests', function () {
const obj = new iObj(connection);

obj.retrPgmInfo('XMLCGI', 'QXMLSERV', (output) => {
expect(getDeprecation().message).to
.equal("As of v1.0, 'iObj.retrPgmInfo()' is deprecated and will be removed at a later time.");
expect(output).to.be.an('Object');
expect(output).to.have.a.property('Program_name');
expect(output).to.have.a.property('Program_library_name');
Expand Down Expand Up @@ -233,6 +257,8 @@ describe('iObj Functional Tests', function () {
const obj = new iObj(connection);

obj.retrSrvPgmInfo('QZSRVSSL', 'QHTTPSVR', (output) => {
expect(getDeprecation().message).to
.equal("As of v1.0, 'iObj.retrSrvPgmInfo()' is deprecated and will be removed at a later time.");
expect(output).to.be.an('Object');
expect(output).to.have.a.property('Service_program_name');
expect(output).to.have.a.property('Service_program_name');
Expand Down Expand Up @@ -288,6 +314,8 @@ describe('iObj Functional Tests', function () {
const obj = new iObj(connection);

obj.retrUserInfo('QSYS', (output) => {
expect(getDeprecation().message).to
.equal("As of v1.0, 'iObj.retrUserInfo()' is deprecated and will be removed at a later time.");
expect(output).to.be.an('Object');
expect(output).to.have.a.property('User_profile_name');
expect(output).to.have.a.property('Previous_sign-on_date_and_time');
Expand All @@ -314,6 +342,8 @@ describe('iObj Functional Tests', function () {
const obj = new iObj(connection);

obj.retrUserAuthToObj('/home', (output) => {
expect(getDeprecation().message).to
.equal("As of v1.0, 'iObj.retrUserAuthToObj()' is deprecated and will be removed at a later time.");
expect(output).to.be.an('Object');
expect(output).to.have.a.property('Profile_name');
expect(output).to.have.a.property('User_or_group_indicator');
Expand Down Expand Up @@ -341,6 +371,8 @@ describe('iObj Functional Tests', function () {
const obj = new iObj(connection);

obj.addToLibraryList('QHTTPSVR', (output) => {
expect(getDeprecation().message).to
.equal("As of v1.0, 'iObj.addToLibraryList()' is deprecated and will be removed at a later time.");
expect(output).to.be.a('boolean').and.to.equal(true);
done();
});
Expand Down
10 changes: 10 additions & 0 deletions test/functional/deprecated/iPgmFunctional.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ if (config.transport === 'rest') {
describe('iPgm Functional Tests', function () {
before(function () {
printConfig();
process.on('deprecation', function () {
// capture depreacation warnings but no-op
// test/unit/iPgmUnit.js already ensures deprecations are emited
});
});

after(function () {
process.removeAllListeners('deprecation', function () {
// no-op
});
});

describe('Test iPgm()', function () {
Expand Down
24 changes: 24 additions & 0 deletions test/functional/deprecated/iProdFunctional.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,25 @@ if (config.transport === 'rest') {
};
}

let deprecation = null;
function deprecationHandler(dep) {
deprecation = dep;
}

function getDeprecation() {
const temp = deprecation;
deprecation = null;
return temp;
}

describe('iProd Functional Tests', function () {
before(function () {
printConfig();
process.on('deprecation', deprecationHandler);
});

after(function () {
process.removeAllListeners('deprecation', deprecationHandler);
});

describe('constructor', function () {
Expand All @@ -53,6 +69,8 @@ describe('iProd Functional Tests', function () {
const prod = new iProd(connection);

expect(prod).to.be.instanceOf(iProd);
expect(getDeprecation().message).to
.equal("As of v1.0, class 'iProd' is deprecated and will be removed at a later time.");
});
});

Expand All @@ -63,6 +81,8 @@ describe('iProd Functional Tests', function () {
const prod = new iProd(connection);

prod.getPTFInfo('SI67726', (ptf) => {
expect(getDeprecation().message).to
.equal("As of v1.0, 'iProd.getPTFInfo()' is deprecated and will be removed at a later time");
expect(ptf).to.be.an('Object');
expect(ptf).to.have.a.property('Product_ID');
expect(ptf).to.have.a.property('PTF_ID');
Expand Down Expand Up @@ -105,6 +125,8 @@ describe('iProd Functional Tests', function () {
const prod = new iProd(connection);

prod.getProductInfo('5770DG1', (product) => {
expect(getDeprecation().message).to
.equal("As of v1.0, 'iProd.getProductInfo()' is deprecated and will be removed at a later time");
expect(product).to.be.an('Object');
expect(product).to.have.a.property('Product_ID');
expect(product).to.have.a.property('Release_level');
Expand Down Expand Up @@ -136,6 +158,8 @@ describe('iProd Functional Tests', function () {
const prod = new iProd(connection);

prod.getInstalledProducts((products) => {
expect(getDeprecation().message).to
.equal("As of v1.0, 'iProd.getInstalledProducts()' is deprecated and will be removed at a later time");
expect(products).to.be.an('Array');
expect(products.length).to.be.greaterThan(0);

Expand Down
10 changes: 10 additions & 0 deletions test/functional/deprecated/iSqlFunctional.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ if (config.transport === 'rest') {
describe('iSql Functional Tests', function () {
before(function () {
printConfig();
process.on('deprecation', function () {
// capture depreacation warnings but no-op
// test/unit/iSqlUnit.js already ensures deprecations are emited
});
});

after(function () {
process.removeAllListeners('deprecation', function () {
// no-op
});
});

describe('prepare & execute', function () {
Expand Down
Loading