Skip to content

Commit

Permalink
#139: add checks on exitCode to every test to ensure no "error" is le…
Browse files Browse the repository at this point in the history
…ft untested
  • Loading branch information
JoernBerkefeld committed Mar 27, 2023
1 parent 2560a20 commit 7469e59
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 3 deletions.
22 changes: 22 additions & 0 deletions test/dataExtension.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('dataExtension', () => {
// WHEN
await handler.retrieve('testInstance/testBU', ['dataExtension']);
// THEN
assert.equal(!!process.exitCode, false, 'retrieve should not have thrown an error');
// get results from cache
const result = cache.getCache();
assert.equal(
Expand Down Expand Up @@ -44,6 +45,7 @@ describe('dataExtension', () => {
// WHEN
await handler.deploy('testInstance/testBU', ['dataExtension']);
// THEN
assert.equal(!!process.exitCode, false, 'deploy should not have thrown an error');

// get results from cache
const result = cache.getCache();
Expand Down Expand Up @@ -81,6 +83,11 @@ describe('dataExtension', () => {
['childBU_dataextension_test'],
'testSourceMarket'
);
assert.equal(
!!process.exitCode,
false,
'retrieveAsTemplate should not have thrown an error'
);

// WHEN
assert.equal(
Expand All @@ -103,6 +110,11 @@ describe('dataExtension', () => {
'childBU_dataextension_test',
'testTargetMarket'
);
assert.equal(
!!process.exitCode,
false,
'buildDefinition should not have thrown an error'
);
assert.deepEqual(
await testUtils.getActualDeployJson(
'childBU_dataextension_testTarget',
Expand All @@ -128,6 +140,11 @@ describe('dataExtension', () => {
['childBU_dataextension_test'],
'testSourceMarket'
);
assert.equal(
!!process.exitCode,
false,
'buildTemplate should not have thrown an error'
);
// WHEN
assert.equal(
result.dataExtension ? Object.keys(result.dataExtension).length : 0,
Expand All @@ -149,6 +166,11 @@ describe('dataExtension', () => {
'childBU_dataextension_test',
'testTargetMarket'
);
assert.equal(
!!process.exitCode,
false,
'buildDefinition should not have thrown an error'
);

assert.deepEqual(
await testUtils.getActualDeployJson(
Expand Down
12 changes: 12 additions & 0 deletions test/interaction.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('interaction', () => {
// WHEN
await handler.retrieve('testInstance/testBU', ['interaction']);
// THEN
assert.equal(!!process.exitCode, false, 'retrieve should not have thrown an error');
// get results from cache
const result = cache.getCache();
assert.equal(
Expand Down Expand Up @@ -47,6 +48,7 @@ describe('interaction', () => {
// WHEN
await handler.deploy('testInstance/testBU', ['interaction']);
// THEN
assert.equal(!!process.exitCode, false, 'deploy should not have thrown an error');
// get results from cache
const result = cache.getCache();
assert.equal(
Expand Down Expand Up @@ -88,6 +90,11 @@ describe('interaction', () => {
['testExisting_interaction'],
'testSourceMarket'
);
assert.equal(
!!process.exitCode,
false,
'buildTemplate should not have thrown an error'
);
assert.equal(
result.interaction ? Object.keys(result.interaction).length : 0,
1,
Expand All @@ -106,6 +113,11 @@ describe('interaction', () => {
'testExisting_interaction',
'testTargetMarket'
);
assert.equal(
!!process.exitCode,
false,
'buildDefinition should not have thrown an error'
);
assert.deepEqual(
await testUtils.getActualDeployJson('testExisting_interaction', 'interaction'),
await testUtils.getExpectedJson('9999999', 'interaction', 'build'),
Expand Down
25 changes: 25 additions & 0 deletions test/query.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe('query', () => {
// WHEN
await handler.retrieve('testInstance/testBU', ['query']);
// THEN
assert.equal(!!process.exitCode, false, 'retrieve should not have thrown an error');
// get results from cache
const result = cache.getCache();
assert.equal(
Expand Down Expand Up @@ -53,6 +54,7 @@ describe('query', () => {
// WHEN
await handler.deploy('testInstance/testBU', ['query']);
// THEN
assert.equal(!!process.exitCode, false, 'deploy should not have thrown an error');
// get results from cache
const result = cache.getCache();
assert.equal(
Expand Down Expand Up @@ -97,6 +99,11 @@ describe('query', () => {
'testSourceMarket'
);
// WHEN
assert.equal(
!!process.exitCode,
false,
'retrieveAsTemplate should not have thrown an error'
);
assert.equal(
result.query ? Object.keys(result.query).length : 0,
1,
Expand All @@ -117,6 +124,12 @@ describe('query', () => {
'testExistingQuery',
'testTargetMarket'
);
assert.equal(
!!process.exitCode,
false,
'buildDefinition should not have thrown an error'
);

assert.deepEqual(
await testUtils.getActualDeployJson('testExistingQuery', 'query'),
await testUtils.getExpectedJson('9999999', 'query', 'build'),
Expand All @@ -143,6 +156,12 @@ describe('query', () => {
'testSourceMarket'
);
// WHEN
assert.equal(
!!process.exitCode,
false,
'buildTemplate should not have thrown an error'
);

assert.equal(
result.query ? Object.keys(result.query).length : 0,
1,
Expand All @@ -163,6 +182,12 @@ describe('query', () => {
'testExistingQuery',
'testTargetMarket'
);
assert.equal(
!!process.exitCode,
false,
'buildDefinition should not have thrown an error'
);

assert.deepEqual(
await testUtils.getActualDeployJson('testExistingQuery', 'query'),
await testUtils.getExpectedJson('9999999', 'query', 'build'),
Expand Down
12 changes: 12 additions & 0 deletions test/transactionalEmail.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('transactionalEmail', () => {
// WHEN
await handler.retrieve('testInstance/testBU', ['transactionalEmail']);
// THEN
assert.equal(!!process.exitCode, false, 'retrieve should not have thrown an error');
// get results from cache
const result = cache.getCache();
assert.equal(
Expand Down Expand Up @@ -47,6 +48,7 @@ describe('transactionalEmail', () => {
// WHEN
await handler.deploy('testInstance/testBU', ['transactionalEmail']);
// THEN
assert.equal(!!process.exitCode, false, 'deploy should not have thrown an error');
// get results from cache
const result = cache.getCache();
assert.equal(
Expand Down Expand Up @@ -87,6 +89,11 @@ describe('transactionalEmail', () => {
['testExisting_temail'],
'testSourceMarket'
);
assert.equal(
!!process.exitCode,
false,
'buildTemplate should not have thrown an error'
);
assert.equal(
result.transactionalEmail ? Object.keys(result.transactionalEmail).length : 0,
1,
Expand All @@ -104,6 +111,11 @@ describe('transactionalEmail', () => {
'testExisting_temail',
'testTargetMarket'
);
assert.equal(
!!process.exitCode,
false,
'buildDefinition should not have thrown an error'
);
assert.deepEqual(
await testUtils.getActualDeployJson('testExisting_temail', 'transactionalEmail'),
await testUtils.getExpectedJson('9999999', 'transactionalEmail', 'build'),
Expand Down
13 changes: 13 additions & 0 deletions test/transactionalPush.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('transactionalPush', () => {
// WHEN
await handler.retrieve('testInstance/testBU', ['transactionalPush']);
// THEN
assert.equal(!!process.exitCode, false, 'retrieve should not have thrown an error');
// get results from cache
const result = cache.getCache();
assert.equal(
Expand Down Expand Up @@ -47,6 +48,7 @@ describe('transactionalPush', () => {
// WHEN
await handler.deploy('testInstance/testBU', ['transactionalPush']);
// THEN
assert.equal(!!process.exitCode, false, 'deploy should not have thrown an error');
// get results from cache
const result = cache.getCache();
assert.equal(
Expand Down Expand Up @@ -87,6 +89,11 @@ describe('transactionalPush', () => {
['testExisting_tpush'],
'testSourceMarket'
);
assert.equal(
!!process.exitCode,
false,
'buildTemplate should not have thrown an error'
);
assert.equal(
result.transactionalPush ? Object.keys(result.transactionalPush).length : 0,
1,
Expand All @@ -104,6 +111,12 @@ describe('transactionalPush', () => {
'testExisting_tpush',
'testTargetMarket'
);
assert.equal(
!!process.exitCode,
false,
'buildDefinition should not have thrown an error'
);

assert.deepEqual(
await testUtils.getActualDeployJson('testExisting_tpush', 'transactionalPush'),
await testUtils.getExpectedJson('9999999', 'transactionalPush', 'build'),
Expand Down
14 changes: 14 additions & 0 deletions test/transactionalSMS.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ describe('transactionalSMS', () => {
// WHEN
await handler.retrieve('testInstance/testBU', ['transactionalSMS']);
// THEN
assert.equal(!!process.exitCode, false, 'retrieve should not have thrown an error');
// get results from cache
const result = cache.getCache();
assert.equal(
Expand Down Expand Up @@ -54,6 +55,7 @@ describe('transactionalSMS', () => {
// WHEN
await handler.deploy('testInstance/testBU', ['transactionalSMS']);
// THEN
assert.equal(!!process.exitCode, false, 'deploy should not have thrown an error');
// get results from cache
const result = cache.getCache();
assert.equal(
Expand Down Expand Up @@ -104,6 +106,12 @@ describe('transactionalSMS', () => {
['testExisting_tsms'],
'testSourceMarket'
);
assert.equal(
!!process.exitCode,
false,
'buildTemplate should not have thrown an error'
);

assert.equal(
result.transactionalSMS ? Object.keys(result.transactionalSMS).length : 0,
1,
Expand All @@ -128,6 +136,12 @@ describe('transactionalSMS', () => {
'testExisting_tsms',
'testTargetMarket'
);
assert.equal(
!!process.exitCode,
false,
'buildDefinition should not have thrown an error'
);

assert.deepEqual(
await testUtils.getActualDeployJson('testExisting_tsms', 'transactionalSMS'),
await testUtils.getExpectedJson('9999999', 'transactionalSMS', 'build'),
Expand Down
16 changes: 13 additions & 3 deletions test/user.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('user', () => {
// WHEN
await handler.retrieve('testInstance/_ParentBU_', ['user']);
// THEN
assert.equal(!!process.exitCode, false, 'retrieve should not have thrown an error');
// get results from cache
const result = cache.getCache();
assert.equal(
Expand Down Expand Up @@ -45,6 +46,7 @@ describe('user', () => {
const expectedCache = ['testNew_user', 'testExisting_user'];
await handler.deploy('testInstance/_ParentBU_', ['user'], expectedCache);
// THEN
assert.equal(!!process.exitCode, false, 'deploy should not have thrown an error');

// get results from cache
const result = cache.getCache();
Expand All @@ -60,8 +62,6 @@ describe('user', () => {
'returned user keys were not equal expected'
);

assert.equal(!!process.exitCode, false, 'Deployment should not have thrown an error');

// insert
assert.deepEqual(
await testUtils.getActualJson('testNew_user', 'user', '_ParentBU_'),
Expand All @@ -86,6 +86,7 @@ describe('user', () => {
const expectedCache = ['testExisting_user'];
await handler.deploy('testInstance/_ParentBU_', ['user'], ['testBlocked_user']);
// THEN
assert.equal(process.exitCode, 1, 'Deployment should have thrown an error');

// get results from cache
const result = cache.getCache();
Expand All @@ -97,7 +98,6 @@ describe('user', () => {
'returned user keys were not equal expected'
);

assert.equal(process.exitCode, 1, 'Deployment should have thrown an error');
assert.equal(
testUtils.getAPIHistoryLength(),
6,
Expand All @@ -118,6 +118,11 @@ describe('user', () => {
['testExisting_user'],
'testSourceMarket'
);
assert.equal(
!!process.exitCode,
false,
'buildTemplate should not have thrown an error'
);
// WHEN
assert.equal(
result.user ? Object.keys(result.user).length : 0,
Expand All @@ -136,6 +141,11 @@ describe('user', () => {
'testExisting_user',
'testTargetMarket'
);
assert.equal(
!!process.exitCode,
false,
'buildDefinition should not have thrown an error'
);

assert.deepEqual(
await testUtils.getActualDeployJson('testExisting_user', 'user', '_ParentBU_'),
Expand Down
3 changes: 3 additions & 0 deletions test/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ exports.mockSetup = (isDeploy) => {
fsMockConf.deploy = fsmock.load(path.resolve(__dirname, 'mockRoot/deploy'));
}
fsmock(fsMockConf);

// ! reset exitCode or else tests could influence each other
process.exitCode = 0;
};

/**
Expand Down

0 comments on commit 7469e59

Please sign in to comment.