Skip to content

Commit

Permalink
#987: add retrieve --like tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JoernBerkefeld committed Jun 28, 2023
1 parent dbc5bcd commit 9784c73
Showing 1 changed file with 56 additions and 1 deletion.
57 changes: 56 additions & 1 deletion test/type.query.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ describe('type: query', () => {
);
return;
});
it('Should retrieve one specific query', async () => {
it('Should retrieve one specific query by key', async () => {
// WHEN
await handler.retrieve('testInstance/testBU', ['query'], ['testExisting_query']);
// THEN
Expand All @@ -80,6 +80,61 @@ describe('type: query', () => {
);
return;
});
it('Should retrieve one specific query via --like', async () => {
// WHEN
handler.setOptions({ like: { key: '%Existing_query' } });
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(
result.query ? Object.keys(result.query).length : 0,
2,
'two queries in cache expected'
);
assert.deepEqual(
await testUtils.getActualJson('testExisting_query', 'query'),
await testUtils.getExpectedJson('9999999', 'query', 'get'),
'returned metadata was not equal expected'
);
expect(file(testUtils.getActualFile('testExisting_query', 'query', 'sql'))).to.equal(
file(testUtils.getExpectedFile('9999999', 'query', 'get', 'sql'))
);
expect(file(testUtils.getActualFile('testExisting_query2', 'query', 'sql'))).to.not
.exist;
assert.equal(
testUtils.getAPIHistoryLength(),
6,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
});
it('Should not retrieve any query via --like and key due to a mismatching filter', async () => {
// WHEN
handler.setOptions({ like: { key: 'NotExisting_query' } });
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(
result.query ? Object.keys(result.query).length : 0,
2,
'two queries in cache expected'
);

expect(file(testUtils.getActualFile('testExisting_query', 'query', 'sql'))).to.not
.exist;
expect(file(testUtils.getActualFile('testExisting_query2', 'query', 'sql'))).to.not
.exist;
assert.equal(
testUtils.getAPIHistoryLength(),
6,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
});
});
describe('Deploy ================', () => {
beforeEach(() => {
Expand Down

0 comments on commit 9784c73

Please sign in to comment.