- 05 Dec 2022
-
DarkLight
-
PDF
Specific Tests - Integration
- Updated on 05 Dec 2022
-
DarkLight
-
PDF
The Adapter Builder will create an integration test for every API method created in the adapter.js file. The following tests are specific to the adapter and can be customized as needed to enhance/ extend testing.
NO MOCK DATA PROVIDED
If there is no mock data, the stub test will test for an error.
The integration test provides the ability to save mock data when running integrated.
runCommonAsserts: This is a private function that tests some basic aspects of a valid response.
runErrorAsserts: This is a private function that tests some basic aspects of a valid error response.
Example: No Mock Data Provided
describe('#createTenant', () => {
it('should work if integrated but since no mockdata should error when run standalone', (done) => {
try {
a.createTenant(tenantName, null, (data, error) => {
try {
if (stub) {
const displayE = 'Error 400 received on request’;
runErrorAsserts(data, error, 'AD.500', 'test-apic-connectorRest-handleEndResponse', displayE);
} else {
runCommonAsserts(data, error);
}
saveMockData('poc-apic', 'createTenant', 'default', data);
done();
} catch (err) {
log.error(`Test Failure: ${err}`);
done(err);
}
});
} catch (error) {
log.error(`Adapter Exception: ${error}`);
done(error);
}
}).timeout(attemptTimeout);
});
MOCK DATA PROVIDED
When mock data has been provided, the stub test will test for the data that is in the mock data file.
Example: Mock Data Approved
describe('#createTenant', () => {
it('should work if integrated but since no mockdata should error when run standalone', (done) => {
try {
a.createTenant(tenantName, null, (data, error) => {
try {
if (stub) {
runCommonAsserts(data, error);
assert.equal('string', data.response.description);
assert.equal('string', data.response.ImportTaskId);
assert.equal('object', typeof data.response.SnapshotTaskDetail);
} else {
runCommonAsserts(data, error);
}
saveMockData('poc-apic', 'createTenant', 'default', data);
done();
} catch (err) {
log.error(`Test Failure: ${err}`);
done(err);
}
});
} catch (error) {
log.error(`Adapter Exception: ${error}`);
done(error);
}
}).timeout(attemptTimeout);
});