Skip to content

Commit 1edfa86

Browse files
#1703: add test for clone method
1 parent 20c0424 commit 1edfa86

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

test/general.test.js

+71
Original file line numberDiff line numberDiff line change
@@ -1398,6 +1398,77 @@ describe('GENERAL', () => {
13981398
);
13991399
});
14001400

1401+
it('clone multiple type with keys', async () => {
1402+
// download first before we test buildTemplate
1403+
await handler.retrieve('testInstance/testBU', ['automation', 'query']);
1404+
1405+
const expectedApiCallsRetrieve = 31;
1406+
assert.equal(
1407+
testUtils.getAPIHistoryLength(),
1408+
expectedApiCallsRetrieve,
1409+
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
1410+
);
1411+
1412+
// preparation
1413+
const argvMetadata = [
1414+
'automation:testExisting_automation',
1415+
'query:testExisting_query',
1416+
'query:bad',
1417+
];
1418+
const typeKeyCombo = handler.metadataToTypeKey(argvMetadata);
1419+
assert.notEqual(
1420+
typeof typeKeyCombo,
1421+
'undefined',
1422+
'typeKeyCombo should not be undefined'
1423+
);
1424+
const buName = 'testInstance/testBU';
1425+
1426+
handler.setOptions({ skipInteraction: true, purge: false });
1427+
// *** build: buildTemplate and buildDefinition chained ***
1428+
const definitionResult = await handler.clone(buName, buName, typeKeyCombo);
1429+
assert.equal(process.exitCode, 0, 'build should not have thrown an error');
1430+
1431+
// *** buildTemplate ***
1432+
// cannot be checked in build anymore because it writes templates into a temporary folder and deletes them afterwards
1433+
1434+
// *** buildDefinition ***
1435+
1436+
// check automation
1437+
assert.equal(
1438+
definitionResult.automation
1439+
? Object.keys(definitionResult.automation).length
1440+
: 0,
1441+
1,
1442+
'only one automation expected'
1443+
);
1444+
assert.deepEqual(
1445+
await testUtils.getActualDeployJson('testExisting_automation', 'automation'),
1446+
await testUtils.getExpectedJson('9999999', 'automation', 'retrieve'),
1447+
'returned deployment file was not equal expected'
1448+
);
1449+
1450+
// check query
1451+
assert.equal(
1452+
definitionResult.query ? Object.keys(definitionResult.query).length : 0,
1453+
1,
1454+
'only one query expected'
1455+
);
1456+
// assert.deepEqual(
1457+
// await testUtils.getActualDeployJson('testExisting_query', 'query'),
1458+
// await testUtils.getExpectedJson('9999999', 'query', 'get'),
1459+
// 'returned deployment JSON was not equal expected'
1460+
// );
1461+
expect(
1462+
await testUtils.getActualDeployFile('testExisting_query', 'query', 'sql')
1463+
).to.equal(await testUtils.getExpectedFile('9999999', 'query', 'get', 'sql'));
1464+
1465+
assert.equal(
1466+
testUtils.getAPIHistoryLength() - expectedApiCallsRetrieve,
1467+
0,
1468+
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
1469+
);
1470+
});
1471+
14011472
it('build multiple type with keys', async () => {
14021473
// download first before we test buildTemplate
14031474
await handler.retrieve('testInstance/testBU', ['automation', 'query']);

0 commit comments

Comments
 (0)