Skip to content

Commit

Permalink
#38: updated test-cases for automatic retrieval after fixKeys
Browse files Browse the repository at this point in the history
  • Loading branch information
JoernBerkefeld committed Aug 2, 2023
1 parent 9121839 commit 9efbfff
Showing 1 changed file with 44 additions and 3 deletions.
47 changes: 44 additions & 3 deletions test/type.query.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ describe('type: query', () => {
});
it('Should NOT fixKeys and deploy', async () => {
// WHEN
handler.setOptions({ skipInteraction: { fixKeysReretrieve: false } });
const resultFixKeys = await handler.fixKeys('testInstance/testBU', 'query', [
'testExisting_query',
]);
Expand Down Expand Up @@ -354,8 +355,9 @@ describe('type: query', () => {
);
return;
});
it('Should fixKeys and deploy by key', async () => {
it('Should fixKeys and deploy by key WITHOUT re-retrieving dependent types', async () => {
// WHEN
handler.setOptions({ skipInteraction: { fixKeysReretrieve: false } });
const resultFixKeys = await handler.fixKeys('testInstance/testBU', 'query', [
'testExisting_query_fixKeys',
'testExisting_query',
Expand Down Expand Up @@ -389,9 +391,48 @@ describe('type: query', () => {
);
return;
});
it('Should fixKeys and deploy via --like', async () => {
it('Should fixKeys and deploy by key AND re-retrieve dependent types', async () => {
// WHEN
handler.setOptions({ like: { key: 'testExisting_query_f%' } });
handler.setOptions({ skipInteraction: { fixKeysReretrieve: true } });
const resultFixKeys = await handler.fixKeys('testInstance/testBU', 'query', [
'testExisting_query_fixKeys',
'testExisting_query',
]);
assert.equal(
resultFixKeys['testInstance/testBU'].length,
1,
'returned number of keys does not correspond to number of expected fixed keys'
);
assert.equal(
resultFixKeys['testInstance/testBU'][0],
'testExisting_query_fixedKeys',
'returned keys do not correspond to expected fixed keys'
);
// THEN
assert.equal(process.exitCode, false, 'fixKeys should not have thrown an error');
// confirm updated item
assert.deepEqual(
await testUtils.getActualJson('testExisting_query_fixedKeys', 'query'),
await testUtils.getExpectedJson('9999999', 'query', 'patch_fixKeys'),
'returned metadata was not equal expected for update query'
);
expect(
file(testUtils.getActualFile('testExisting_query_fixedKeys', 'query', 'sql'))
).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'patch_fixKeys', 'sql')));
// check number of API calls
assert.equal(
testUtils.getAPIHistoryLength(),
31,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
});
it('Should fixKeys and deploy via --like WITHOUT re-retrieving dependent types', async () => {
// WHEN
handler.setOptions({
like: { key: 'testExisting_query_f%' },
skipInteraction: { fixKeysReretrieve: false },
});
const resultFixKeys = await handler.fixKeys('testInstance/testBU', 'query');
assert.equal(
resultFixKeys['testInstance/testBU'].length,
Expand Down

0 comments on commit 9efbfff

Please sign in to comment.