mcdev 5.0.2 → 5.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.coverage-comment-template.svelte +177 -161
- package/.eslintrc.json +4 -4
- package/.github/ISSUE_TEMPLATE/bug.yml +2 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +2 -2
- package/.github/dependabot.yml +8 -0
- package/.github/workflows/coverage-base-update.yml +6 -2
- package/.github/workflows/coverage-develop-branch.yml +7 -8
- package/.github/workflows/coverage-main-branch.yml +7 -8
- package/.github/workflows/coverage.yml +7 -4
- package/.husky/post-checkout +4 -2
- package/.husky/post-merge +1 -0
- package/.vscode/extensions.json +4 -0
- package/docs/dist/documentation.md +756 -294
- package/lib/Deployer.js +28 -28
- package/lib/MetadataTypeDefinitions.js +1 -1
- package/lib/MetadataTypeInfo.js +1 -1
- package/lib/Retriever.js +1 -1
- package/lib/cli.js +184 -6
- package/lib/index.js +493 -22
- package/lib/metadataTypes/Asset.js +10 -11
- package/lib/metadataTypes/AttributeGroup.js +76 -2
- package/lib/metadataTypes/AttributeSet.js +260 -0
- package/lib/metadataTypes/Automation.js +771 -247
- package/lib/metadataTypes/DataExtension.js +7 -7
- package/lib/metadataTypes/DataExtensionField.js +1 -1
- package/lib/metadataTypes/Event.js +2 -3
- package/lib/metadataTypes/Folder.js +1 -1
- package/lib/metadataTypes/Journey.js +5 -6
- package/lib/metadataTypes/MetadataType.js +187 -60
- package/lib/metadataTypes/MobileKeyword.js +8 -8
- package/lib/metadataTypes/MobileMessage.js +5 -5
- package/lib/metadataTypes/Query.js +47 -5
- package/lib/metadataTypes/Script.js +3 -3
- package/lib/metadataTypes/TransactionalSMS.js +5 -5
- package/lib/metadataTypes/TriggeredSend.js +25 -50
- package/lib/metadataTypes/User.js +7 -4
- package/lib/metadataTypes/definitions/Asset.definition.js +1 -0
- package/lib/metadataTypes/definitions/AttributeGroup.definition.js +117 -106
- package/lib/metadataTypes/definitions/{SetDefinition.definition.js → AttributeSet.definition.js} +54 -27
- package/lib/metadataTypes/definitions/Automation.definition.js +74 -21
- package/lib/metadataTypes/definitions/DataExtension.definition.js +1 -0
- package/lib/metadataTypes/definitions/DataExtract.definition.js +1 -0
- package/lib/metadataTypes/definitions/EmailSend.definition.js +1 -0
- package/lib/metadataTypes/definitions/Event.definition.js +1 -0
- package/lib/metadataTypes/definitions/Filter.definition.js +1 -0
- package/lib/metadataTypes/definitions/ImportFile.definition.js +37 -6
- package/lib/metadataTypes/definitions/MobileKeyword.definition.js +1 -0
- package/lib/metadataTypes/definitions/Query.definition.js +1 -0
- package/lib/metadataTypes/definitions/Role.definition.js +1 -0
- package/lib/metadataTypes/definitions/TriggeredSend.definition.js +2 -0
- package/lib/metadataTypes/definitions/User.definition.js +1 -0
- package/lib/util/cache.js +9 -4
- package/lib/util/cli.js +40 -0
- package/lib/util/devops.js +13 -11
- package/lib/util/file.js +2 -2
- package/lib/util/init.js +84 -0
- package/lib/util/util.js +268 -137
- package/package.json +11 -11
- package/test/general.test.js +26 -0
- package/test/mockRoot/.mcdevrc.json +1 -1
- package/test/mockRoot/deploy/testInstance/testBU/automation/testExisting_automation.automation-meta.json +52 -0
- package/test/mockRoot/deploy/testInstance/testBU/automation/testNew_automation.automation-meta.json +45 -0
- package/test/mockRoot/deploy/testInstance/testBU/dataExtract/testExisting_dataExtract.dataExtract-meta.json +35 -0
- package/test/mockRoot/deploy/testInstance/testBU/dataExtract/testNew_dataExtract.dataExtract-meta.json +35 -0
- package/test/mockRoot/deploy/testInstance/testBU/fileTransfer/testExisting_fileTransfer.fileTransfer-meta.json +17 -0
- package/test/mockRoot/deploy/testInstance/testBU/fileTransfer/testNew_fileTransfer.fileTransfer-meta.json +17 -0
- package/test/mockRoot/deploy/testInstance/testBU/importFile/testExisting_importFile.importFile-meta.json +29 -0
- package/test/mockRoot/deploy/testInstance/testBU/importFile/testNew_importFile.importFile-meta.json +29 -0
- package/test/mockRoot/deploy/testInstance/testBU/query/{testExistingQuery.query-meta.json → testExisting_query.query-meta.json} +2 -2
- package/test/mockRoot/deploy/testInstance/testBU/query/testExisting_query_fixKeys.query-meta.json +11 -0
- package/test/mockRoot/deploy/testInstance/testBU/query/testExisting_query_fixKeys.query-meta.sql +6 -0
- package/test/mockRoot/deploy/testInstance/testBU/query/{testNewQuery.query-meta.json → testNew_query.query-meta.json} +2 -2
- package/test/mockRoot/deploy/testInstance/testBU/script/testExisting_script.script-meta.json +6 -0
- package/test/mockRoot/deploy/testInstance/testBU/script/testExisting_script.script-meta.ssjs +1 -0
- package/test/mockRoot/deploy/testInstance/testBU/script/testNew_script.script-meta.json +6 -0
- package/test/mockRoot/deploy/testInstance/testBU/script/testNew_script.script-meta.ssjs +1 -0
- package/test/mockRoot/deploy/testInstance/testBU/triggeredSend/testExisting_triggeredSend.triggeredSend-meta.json +29 -0
- package/test/mockRoot/deploy/testInstance/testBU/triggeredSend/testNew_triggeredSend.triggeredSend-meta.json +29 -0
- package/test/resourceFactory.js +132 -24
- package/test/resources/1111111/accountUser/retrieve-ActiveFlag=falseANDCustomerKey=testExisting_userANDEmaillike@-response.xml +27 -0
- package/test/resources/1111111/accountUser/retrieve-ActiveFlag=falseANDEmaillike@-response.xml +156 -0
- package/test/resources/1111111/accountUser/retrieve-ActiveFlag=trueANDEmailisNullORNamelikeapp userANDMustChangePassword=false-response.xml +87 -0
- package/test/resources/1111111/accountUser/retrieve-ActiveFlag=trueANDEmaillike@-response.xml +156 -0
- package/test/resources/1111111/accountUser/retrieve-CustomerKey=testExisting_userANDActiveFlag=trueANDEmailisNullORNamelikeapp userANDMustChangePassword=false-response.xml +27 -0
- package/test/resources/1111111/accountUserAccount/retrieve-AccountUser.AccountUserID=700301950-response.xml +60 -0
- package/test/resources/1111111/user/retrieve-expected.md +4 -2
- package/test/resources/9999999/attributeGroup/retrieve-expected.json +25 -0
- package/test/resources/9999999/attributeSet/retrieve-expected.json +748 -0
- package/test/resources/9999999/automation/build-expected.json +57 -0
- package/test/resources/9999999/automation/create-expected.json +45 -0
- package/test/resources/9999999/automation/create-testNew_automation-expected.md +28 -0
- package/test/resources/9999999/automation/delete-response.xml +40 -0
- package/test/resources/9999999/automation/patch_fixKeys-pause-expected.json +44 -0
- package/test/resources/9999999/automation/patch_fixKeys-schedule-expected.json +44 -0
- package/test/resources/9999999/automation/perform-08afb0e2-b00a-4c88-ad2e-1f7f8788c560-response.xml +42 -0
- package/test/resources/9999999/automation/perform-08afb0e2-b00a-4c88-fixKey_pause-response.xml +42 -0
- package/test/resources/9999999/automation/perform-08afb0e2-b00a-4c88-fixKey_schedule-response.xml +42 -0
- package/test/resources/9999999/automation/perform-a8afb0e2-b00a-4c88-ad2e-1f7f8788c560-response.xml +42 -0
- package/test/resources/9999999/automation/retrieve-expected.json +57 -0
- package/test/resources/9999999/automation/retrieve-testExisting_automation-expected.md +30 -0
- package/test/resources/9999999/automation/schedule-08afb0e2-b00a-4c88-ad2e-1f7f8788c560-response.xml +52 -0
- package/test/resources/9999999/automation/schedule-08afb0e2-b00a-4c88-ad2e-pause-response.xml +38 -0
- package/test/resources/9999999/automation/schedule-08afb0e2-b00a-4c88-fixKey_pause-response.xml +52 -0
- package/test/resources/9999999/automation/schedule-08afb0e2-b00a-4c88-fixKey_schedule-response.xml +52 -0
- package/test/resources/9999999/automation/schedule-a8afb0e2-b00a-4c88-ad2e-1f7f8788c560-response.xml +52 -0
- package/test/resources/9999999/automation/template-expected.json +57 -0
- package/test/resources/9999999/automation/update-expected.json +45 -0
- package/test/resources/9999999/automation/update-testExisting_automation-expected.md +28 -0
- package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-1f7f8788c560/get-response.json +85 -0
- package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-1f7f8788c560/patch-response.json +85 -0
- package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-pause/get-response.json +85 -0
- package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-pause/patch-response.json +85 -0
- package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-fixKey_pause/get-response.json +85 -0
- package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-fixKey_pause/patch-response.json +85 -0
- package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-fixKey_schedule/get-response.json +85 -0
- package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-fixKey_schedule/patch-response.json +85 -0
- package/test/resources/9999999/automation/v1/automations/a8afb0e2-b00a-4c88-ad2e-1f7f8788c560/get-response.json +85 -0
- package/test/resources/9999999/automation/v1/automations/post-response.json +86 -0
- package/test/resources/9999999/automation/v1/dataextracts/56c5370a-f988-4f36-b0ee-0f876573f6d7/get-response.json +38 -0
- package/test/resources/9999999/automation/v1/dataextracts/56c5370a-f988-4f36-b0ee-0f876573f6d7/patch-response.json +38 -0
- package/test/resources/9999999/automation/v1/dataextracts/get-response.json +20 -0
- package/test/resources/9999999/automation/v1/dataextracts/post-response.json +38 -0
- package/test/resources/9999999/automation/v1/dataextracttypes/get-response.json +50 -0
- package/test/resources/9999999/automation/v1/filetransfers/72c328ac-f5b0-4e37-91d3-a775666f15a6/get-response.json +18 -0
- package/test/resources/9999999/automation/v1/filetransfers/72c328ac-f5b0-4e37-91d3-a775666f15a6/patch-response.json +18 -0
- package/test/resources/9999999/automation/v1/filetransfers/get-response.json +15 -0
- package/test/resources/9999999/automation/v1/filetransfers/post-response.json +18 -0
- package/test/resources/9999999/automation/v1/ftplocations/get-response.json +18 -0
- package/test/resources/9999999/automation/v1/imports/9d16f42c-2260-ed11-b849-48df37d1de8b/patch-response.json +31 -0
- package/test/resources/9999999/automation/v1/imports/get-response.json +38 -0
- package/test/resources/9999999/automation/v1/imports/post-response.json +30 -0
- package/test/resources/9999999/automation/v1/queries/549f0568-607c-4940-afef-437965094dae/actions/start/post-response.txt +1 -0
- package/test/resources/9999999/automation/v1/queries/549f0568-607c-4940-afef-437965094dat/actions/start/post-response.txt +1 -0
- package/test/resources/9999999/automation/v1/queries/549f0568-607c-4940-afef-437965094dat/get-response.json +2 -2
- package/test/resources/9999999/automation/v1/queries/549f0568-607c-4940-afef-437965094dat/patch-response.json +2 -2
- package/test/resources/9999999/automation/v1/queries/549f0568-607c-4940-afef-437965094dat_fixKeys/get-response.json +17 -0
- package/test/resources/9999999/automation/v1/queries/549f0568-607c-4940-afef-437965094dat_fixKeys/patch-response.json +18 -0
- package/test/resources/9999999/automation/v1/queries/get-response.json +22 -5
- package/test/resources/9999999/automation/v1/queries/post-response.json +2 -2
- package/test/resources/9999999/automation/v1/scripts/39f6a488-20eb-4ba0-b0b9-023725b574e4/patch-response.json +10 -0
- package/test/resources/9999999/automation/v1/scripts/get-response.json +27 -0
- package/test/resources/9999999/automation/v1/scripts/post-response.json +10 -0
- package/test/resources/9999999/dataExtension/retrieve-Name=testExisting_dataExtension-response.xml +52 -0
- package/test/resources/9999999/dataExtensionField/retrieve-DataExtension.CustomerKey=testExisting_dataExtension-response.xml +98 -0
- package/test/resources/9999999/dataExtensionField/retrieve-DataExtension.CustomerKey=testNew_dataExtensionORDataExtension.CustomerKey=testExisting_dataExtension-response.xml +99 -0
- package/test/resources/9999999/dataExtract/build-expected.json +35 -0
- package/test/resources/9999999/dataExtract/get-expected.json +39 -0
- package/test/resources/9999999/dataExtract/patch-expected.json +37 -0
- package/test/resources/9999999/dataExtract/post-expected.json +37 -0
- package/test/resources/9999999/dataExtract/template-expected.json +35 -0
- package/test/resources/9999999/dataFolder/retrieve-ContentType=automations-response.xml +48 -0
- package/test/resources/9999999/dataFolder/retrieve-ContentType=contextual_suppression_listORContentType=publicationORContentType=suppression_listORContentType=mysubsORContentType=list-response.xml +136 -0
- package/test/resources/9999999/dataFolder/retrieve-ContentType=queryactivity-response.xml +48 -0
- package/test/resources/9999999/dataFolder/retrieve-ContentType=ssjsactivity-response.xml +48 -0
- package/test/resources/9999999/dataFolder/retrieve-ContentType=triggered_send_journeybuilderORContentType=triggered_sendORContentType=hidden-response.xml +276 -0
- package/test/resources/9999999/dataFolder/retrieve-response.xml +45 -0
- package/test/resources/9999999/email/retrieve-response.xml +203 -0
- package/test/resources/9999999/emailSendDefinition/retrieve-IsPlatformObject=falseANDDescriptionnotEqualsSFSendDefinition-response.xml +85 -0
- package/test/resources/9999999/fileTransfer/build-expected.json +15 -0
- package/test/resources/9999999/fileTransfer/get-expected.json +17 -0
- package/test/resources/9999999/fileTransfer/patch-expected.json +17 -0
- package/test/resources/9999999/fileTransfer/post-expected.json +17 -0
- package/test/resources/9999999/fileTransfer/template-expected.json +15 -0
- package/test/resources/9999999/hub/v1/contacts/schema/attributeGroups/get-response.json +585 -0
- package/test/resources/9999999/hub/v1/contacts/schema/setDefinitions/get-response.json +19807 -0
- package/test/resources/9999999/importFile/build-expected.json +27 -0
- package/test/resources/9999999/importFile/get-expected.json +29 -0
- package/test/resources/9999999/importFile/patch-expected.json +29 -0
- package/test/resources/9999999/importFile/post-expected.json +29 -0
- package/test/resources/9999999/importFile/template-expected.json +27 -0
- package/test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow/get-response.json +21 -0
- package/test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow/post-response.json +0 -0
- package/test/resources/9999999/legacy/v1/beta/bulk/automations/automation/definition/get-response.json +30 -0
- package/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation-response.xml +30 -0
- package/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_fixKey_pause-response.xml +32 -0
- package/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_fixKey_schedule-response.xml +32 -0
- package/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_fixedKey_paused-response.xml +32 -0
- package/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_fixedKey_scheduled-response.xml +32 -0
- package/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_pause-response.xml +30 -0
- package/test/resources/9999999/program/retrieve-CustomerKey=testNew_automation-response.xml +30 -0
- package/test/resources/9999999/program/retrieve-Name=testExisting_automation-response.xml +31 -0
- package/test/resources/9999999/program/retrieve-response.xml +50 -0
- package/test/resources/9999999/query/build-expected.json +2 -2
- package/test/resources/9999999/query/get-expected.json +2 -2
- package/test/resources/9999999/query/get2-expected.json +2 -2
- package/test/resources/9999999/query/patch-expected.json +2 -2
- package/test/resources/9999999/query/patch_fixKeys-expected.json +11 -0
- package/test/resources/9999999/query/patch_fixKeys-expected.sql +6 -0
- package/test/resources/9999999/query/post-expected.json +2 -2
- package/test/resources/9999999/query/template-expected.json +2 -2
- package/test/resources/9999999/queryDefinition/retrieve-CustomerKey=testExisting_query_fixKeysANDStatus=Active-response.xml +30 -0
- package/test/resources/9999999/queryDefinition/retrieve-CustomerKey=testExisting_query_fixedKeysANDStatus=Active-response.xml +30 -0
- package/test/resources/9999999/queryDefinition/retrieve-CustomerKey=testNew_queryANDStatus=Active-response.xml +30 -0
- package/test/resources/9999999/script/build-expected.json +6 -0
- package/test/resources/9999999/script/build-expected.ssjs +1 -0
- package/test/resources/9999999/script/get-expected.json +8 -0
- package/test/resources/9999999/script/get-expected.ssjs +1 -0
- package/test/resources/9999999/script/get_noScriptTag-expected.html +1 -0
- package/test/resources/9999999/script/get_noScriptTag-expected.json +8 -0
- package/test/resources/9999999/script/patch-expected.json +8 -0
- package/test/resources/9999999/script/patch-expected.ssjs +1 -0
- package/test/resources/9999999/script/post-expected.json +8 -0
- package/test/resources/9999999/script/post-expected.ssjs +1 -0
- package/test/resources/9999999/script/template-expected.json +6 -0
- package/test/resources/9999999/script/template-expected.ssjs +1 -0
- package/test/resources/9999999/triggeredSend/build-expected.json +29 -0
- package/test/resources/9999999/triggeredSend/get-expected.json +29 -0
- package/test/resources/9999999/triggeredSend/patch-expected.json +29 -0
- package/test/resources/9999999/triggeredSend/post-expected.json +29 -0
- package/test/resources/9999999/triggeredSend/template-expected.json +29 -0
- package/test/resources/9999999/triggeredSendDefinition/create-response.xml +75 -0
- package/test/resources/9999999/triggeredSendDefinition/delete-response.xml +36 -0
- package/test/resources/9999999/triggeredSendDefinition/{retrieve-response.xml → retrieve-TriggeredSendStatusINNew,Active,Inactive,Moved,Canceled-response.xml} +4 -4
- package/test/resources/9999999/triggeredSendDefinition/update-response.xml +74 -0
- package/test/type.attributeGroup.test.js +55 -0
- package/test/type.attributeSet.test.js +55 -0
- package/test/type.automation.test.js +886 -0
- package/test/type.dataExtension.test.js +3 -1
- package/test/type.dataExtract.test.js +187 -0
- package/test/type.fileTransfer.test.js +185 -0
- package/test/type.importFile.test.js +186 -0
- package/test/type.mobileKeyword.test.js +0 -1
- package/test/type.query.test.js +497 -33
- package/test/type.script.test.js +367 -0
- package/test/type.triggeredSend.test.js +152 -0
- package/test/type.user.test.js +37 -11
- package/test/utils.js +10 -6
- package/.coverage-comment-template.md +0 -20
- package/lib/metadataTypes/SetDefinition.js +0 -37
- /package/test/mockRoot/deploy/testInstance/testBU/query/{testExistingQuery.query-meta.sql → testExisting_query.query-meta.sql} +0 -0
- /package/test/mockRoot/deploy/testInstance/testBU/query/{testNewQuery.query-meta.sql → testNew_query.query-meta.sql} +0 -0
- /package/test/resources/1111111/accountUser/{retrieve-response.xml → retrieve-ActiveFlag=trueANDCustomerKey=testExisting_userANDEmaillike@-response.xml} +0 -0
- /package/test/resources/1111111/accountUserAccount/{retrieve-response.xml → retrieve-AccountUser.AccountUserIDIN700301950,700301951,7471228-response.xml} +0 -0
- /package/test/resources/1111111/businessUnit/{retrieve-response.xml → retrieve-ID=1111111-response.xml} +0 -0
- /package/test/resources/1111111/list/{retrieve-response.xml → retrieve-CustomerKey=All SubscribersORListName=All Subscribers-response.xml} +0 -0
- /package/test/resources/1111111/role/{retrieve-response.xml → retrieve-IsPrivate=false-response.xml} +0 -0
- /package/test/resources/9999999/queryDefinition/{retrieve-response.xml → retrieve-CustomerKey=testExisting_queryANDStatus=Active-response.xml} +0 -0
|
@@ -0,0 +1,886 @@
|
|
|
1
|
+
const chai = require('chai');
|
|
2
|
+
const chaiFiles = require('chai-files');
|
|
3
|
+
|
|
4
|
+
chai.use(chaiFiles);
|
|
5
|
+
|
|
6
|
+
const assert = chai.assert;
|
|
7
|
+
const expect = chai.expect;
|
|
8
|
+
const file = chaiFiles.file;
|
|
9
|
+
const cache = require('../lib/util/cache');
|
|
10
|
+
const testUtils = require('./utils');
|
|
11
|
+
const handler = require('../lib/index');
|
|
12
|
+
|
|
13
|
+
describe('type: automation', () => {
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
testUtils.mockSetup();
|
|
16
|
+
});
|
|
17
|
+
afterEach(() => {
|
|
18
|
+
testUtils.mockReset();
|
|
19
|
+
});
|
|
20
|
+
describe('Retrieve ================', () => {
|
|
21
|
+
it('Should retrieve a automation', async () => {
|
|
22
|
+
// WHEN
|
|
23
|
+
await handler.retrieve('testInstance/testBU', ['automation']);
|
|
24
|
+
// THEN
|
|
25
|
+
assert.equal(process.exitCode, false, 'retrieve should not have thrown an error');
|
|
26
|
+
// get results from cache
|
|
27
|
+
const result = cache.getCache();
|
|
28
|
+
assert.equal(
|
|
29
|
+
result.automation ? Object.keys(result.automation).length : 0,
|
|
30
|
+
4,
|
|
31
|
+
'only four automations expected'
|
|
32
|
+
);
|
|
33
|
+
assert.deepEqual(
|
|
34
|
+
await testUtils.getActualJson('testExisting_automation', 'automation'),
|
|
35
|
+
await testUtils.getExpectedJson('9999999', 'automation', 'retrieve'),
|
|
36
|
+
|
|
37
|
+
'returned metadata was not equal expected'
|
|
38
|
+
);
|
|
39
|
+
// check if MD file was created and equals expectations
|
|
40
|
+
expect(file(testUtils.getActualDoc('testExisting_automation', 'automation'))).to.equal(
|
|
41
|
+
file(
|
|
42
|
+
testUtils.getExpectedFile(
|
|
43
|
+
'9999999',
|
|
44
|
+
'automation',
|
|
45
|
+
'retrieve-testExisting_automation',
|
|
46
|
+
'md'
|
|
47
|
+
)
|
|
48
|
+
)
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
assert.equal(
|
|
52
|
+
testUtils.getAPIHistoryLength(),
|
|
53
|
+
17,
|
|
54
|
+
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
|
|
55
|
+
);
|
|
56
|
+
return;
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
describe('Deploy ================', () => {
|
|
60
|
+
beforeEach(() => {
|
|
61
|
+
testUtils.mockSetup(true);
|
|
62
|
+
});
|
|
63
|
+
it('Should create & update a automation', async () => {
|
|
64
|
+
// WHEN
|
|
65
|
+
const deployResult = await handler.deploy('testInstance/testBU', ['automation']);
|
|
66
|
+
// THEN
|
|
67
|
+
assert.equal(process.exitCode, false, 'deploy should not have thrown an error');
|
|
68
|
+
|
|
69
|
+
// check how many items were deployed
|
|
70
|
+
assert.equal(
|
|
71
|
+
deployResult['testInstance/testBU']?.automation
|
|
72
|
+
? Object.keys(deployResult['testInstance/testBU']?.automation).length
|
|
73
|
+
: 0,
|
|
74
|
+
2,
|
|
75
|
+
'two automations to be deployed'
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
// get results from cache
|
|
79
|
+
const cacheResult = cache.getCache();
|
|
80
|
+
assert.equal(
|
|
81
|
+
cacheResult.automation ? Object.keys(cacheResult.automation).length : 0,
|
|
82
|
+
5,
|
|
83
|
+
'three automations expected'
|
|
84
|
+
);
|
|
85
|
+
// insert
|
|
86
|
+
assert.deepEqual(
|
|
87
|
+
await testUtils.getActualJson('testNew_automation', 'automation'),
|
|
88
|
+
await testUtils.getExpectedJson('9999999', 'automation', 'create'),
|
|
89
|
+
'returned metadata was not equal expected for create'
|
|
90
|
+
);
|
|
91
|
+
// update
|
|
92
|
+
assert.deepEqual(
|
|
93
|
+
await testUtils.getActualJson('testExisting_automation', 'automation'),
|
|
94
|
+
await testUtils.getExpectedJson('9999999', 'automation', 'update'),
|
|
95
|
+
'returned metadata was not equal expected for update'
|
|
96
|
+
);
|
|
97
|
+
// check if MD file was created and equals expectations
|
|
98
|
+
expect(file(testUtils.getActualDoc('testExisting_automation', 'automation'))).to.equal(
|
|
99
|
+
file(
|
|
100
|
+
testUtils.getExpectedFile(
|
|
101
|
+
'9999999',
|
|
102
|
+
'automation',
|
|
103
|
+
'update-testExisting_automation',
|
|
104
|
+
'md'
|
|
105
|
+
)
|
|
106
|
+
)
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
// check if MD file was created and equals expectations
|
|
110
|
+
expect(file(testUtils.getActualDoc('testNew_automation', 'automation'))).to.equal(
|
|
111
|
+
file(
|
|
112
|
+
testUtils.getExpectedFile(
|
|
113
|
+
'9999999',
|
|
114
|
+
'automation',
|
|
115
|
+
'create-testNew_automation',
|
|
116
|
+
'md'
|
|
117
|
+
)
|
|
118
|
+
)
|
|
119
|
+
);
|
|
120
|
+
|
|
121
|
+
assert.equal(
|
|
122
|
+
testUtils.getAPIHistoryLength(),
|
|
123
|
+
16,
|
|
124
|
+
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
|
|
125
|
+
);
|
|
126
|
+
return;
|
|
127
|
+
});
|
|
128
|
+
it('Should update & schedule an automation with --schedule option', async () => {
|
|
129
|
+
// WHEN
|
|
130
|
+
handler.setOptions({ schedule: true });
|
|
131
|
+
const deployed = await handler.deploy(
|
|
132
|
+
'testInstance/testBU',
|
|
133
|
+
['automation'],
|
|
134
|
+
['testExisting_automation', 'testNew_automation']
|
|
135
|
+
);
|
|
136
|
+
// THEN
|
|
137
|
+
assert.equal(
|
|
138
|
+
process.exitCode,
|
|
139
|
+
false,
|
|
140
|
+
'deploy with --execute should not have thrown an error'
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
// get results from cache
|
|
144
|
+
const cached = cache.getCache();
|
|
145
|
+
assert.equal(
|
|
146
|
+
cached.automation ? Object.keys(cached.automation).length : 0,
|
|
147
|
+
5,
|
|
148
|
+
'five cached automation expected'
|
|
149
|
+
);
|
|
150
|
+
assert.equal(
|
|
151
|
+
deployed['testInstance/testBU'].automation
|
|
152
|
+
? Object.keys(deployed['testInstance/testBU'].automation).length
|
|
153
|
+
: 0,
|
|
154
|
+
2,
|
|
155
|
+
'two deployed automation expected'
|
|
156
|
+
);
|
|
157
|
+
assert.equal(
|
|
158
|
+
deployed['testInstance/testBU'].automation
|
|
159
|
+
? Object.keys(deployed['testInstance/testBU'].automation)[0]
|
|
160
|
+
: null,
|
|
161
|
+
'testNew_automation',
|
|
162
|
+
'expected specific automation to have been deployed'
|
|
163
|
+
);
|
|
164
|
+
assert.equal(
|
|
165
|
+
deployed['testInstance/testBU'].automation
|
|
166
|
+
? Object.keys(deployed['testInstance/testBU'].automation)[1]
|
|
167
|
+
: null,
|
|
168
|
+
'testExisting_automation',
|
|
169
|
+
'expected specific automation to have been deployed'
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
// update
|
|
173
|
+
assert.deepEqual(
|
|
174
|
+
await testUtils.getActualJson('testExisting_automation', 'automation'),
|
|
175
|
+
await testUtils.getExpectedJson('9999999', 'automation', 'update'),
|
|
176
|
+
'returned metadata was not equal expected for update'
|
|
177
|
+
);
|
|
178
|
+
// check if MD file was created and equals expectations
|
|
179
|
+
expect(file(testUtils.getActualDoc('testExisting_automation', 'automation'))).to.equal(
|
|
180
|
+
file(
|
|
181
|
+
testUtils.getExpectedFile(
|
|
182
|
+
'9999999',
|
|
183
|
+
'automation',
|
|
184
|
+
'update-testExisting_automation',
|
|
185
|
+
'md'
|
|
186
|
+
)
|
|
187
|
+
)
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
assert.equal(
|
|
191
|
+
testUtils.getAPIHistoryLength(),
|
|
192
|
+
24,
|
|
193
|
+
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
|
|
194
|
+
);
|
|
195
|
+
return;
|
|
196
|
+
});
|
|
197
|
+
it('Should update & runOnce an automation with --execute option', async () => {
|
|
198
|
+
// WHEN
|
|
199
|
+
handler.setOptions({ execute: true });
|
|
200
|
+
const deployed = await handler.deploy(
|
|
201
|
+
'testInstance/testBU',
|
|
202
|
+
['automation'],
|
|
203
|
+
['testExisting_automation', 'testNew_automation']
|
|
204
|
+
);
|
|
205
|
+
// THEN
|
|
206
|
+
assert.equal(
|
|
207
|
+
process.exitCode,
|
|
208
|
+
false,
|
|
209
|
+
'deploy with --execute should not have thrown an error'
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
// get results from cache
|
|
213
|
+
const cached = cache.getCache();
|
|
214
|
+
assert.equal(
|
|
215
|
+
cached.automation ? Object.keys(cached.automation).length : 0,
|
|
216
|
+
5,
|
|
217
|
+
'five cached automation expected'
|
|
218
|
+
);
|
|
219
|
+
assert.equal(
|
|
220
|
+
deployed['testInstance/testBU'].automation
|
|
221
|
+
? Object.keys(deployed['testInstance/testBU'].automation).length
|
|
222
|
+
: 0,
|
|
223
|
+
2,
|
|
224
|
+
'two deployed automation expected'
|
|
225
|
+
);
|
|
226
|
+
assert.equal(
|
|
227
|
+
deployed['testInstance/testBU'].automation
|
|
228
|
+
? Object.keys(deployed['testInstance/testBU'].automation)[0]
|
|
229
|
+
: null,
|
|
230
|
+
'testNew_automation',
|
|
231
|
+
'expected specific automation to have been deployed'
|
|
232
|
+
);
|
|
233
|
+
assert.equal(
|
|
234
|
+
deployed['testInstance/testBU'].automation
|
|
235
|
+
? Object.keys(deployed['testInstance/testBU'].automation)[1]
|
|
236
|
+
: null,
|
|
237
|
+
'testExisting_automation',
|
|
238
|
+
'expected specific automation to have been deployed'
|
|
239
|
+
);
|
|
240
|
+
// update
|
|
241
|
+
assert.deepEqual(
|
|
242
|
+
await testUtils.getActualJson('testExisting_automation', 'automation'),
|
|
243
|
+
await testUtils.getExpectedJson('9999999', 'automation', 'update'),
|
|
244
|
+
'returned metadata was not equal expected for update'
|
|
245
|
+
);
|
|
246
|
+
// check if MD file was created and equals expectations
|
|
247
|
+
expect(file(testUtils.getActualDoc('testExisting_automation', 'automation'))).to.equal(
|
|
248
|
+
file(
|
|
249
|
+
testUtils.getExpectedFile(
|
|
250
|
+
'9999999',
|
|
251
|
+
'automation',
|
|
252
|
+
'update-testExisting_automation',
|
|
253
|
+
'md'
|
|
254
|
+
)
|
|
255
|
+
)
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
assert.equal(
|
|
259
|
+
testUtils.getAPIHistoryLength(),
|
|
260
|
+
20,
|
|
261
|
+
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
|
|
262
|
+
);
|
|
263
|
+
return;
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
describe('FixKeys ================', () => {
|
|
267
|
+
beforeEach(() => {
|
|
268
|
+
testUtils.mockSetup(true);
|
|
269
|
+
});
|
|
270
|
+
it('Should run fixKeys but not find fixable keys and hence stop', async () => {
|
|
271
|
+
// WHEN
|
|
272
|
+
handler.setOptions({ skipInteraction: { fixKeysReretrieve: false } });
|
|
273
|
+
const resultFixKeys = await handler.fixKeys('testInstance/testBU', 'automation', [
|
|
274
|
+
'testExisting_automation',
|
|
275
|
+
]);
|
|
276
|
+
// THEN
|
|
277
|
+
assert.equal(process.exitCode, false, 'fixKeys should not have thrown an error');
|
|
278
|
+
// check which keys were fixed
|
|
279
|
+
assert.equal(
|
|
280
|
+
resultFixKeys['testInstance/testBU'].length,
|
|
281
|
+
0,
|
|
282
|
+
'expected to find no keys to be fixed'
|
|
283
|
+
);
|
|
284
|
+
|
|
285
|
+
// get results from cache
|
|
286
|
+
const result = cache.getCache();
|
|
287
|
+
assert.equal(
|
|
288
|
+
result.automation ? Object.keys(result.automation).length : 0,
|
|
289
|
+
1,
|
|
290
|
+
'one automation expected'
|
|
291
|
+
);
|
|
292
|
+
// check number of API calls
|
|
293
|
+
assert.equal(
|
|
294
|
+
testUtils.getAPIHistoryLength(),
|
|
295
|
+
14,
|
|
296
|
+
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
|
|
297
|
+
);
|
|
298
|
+
return;
|
|
299
|
+
});
|
|
300
|
+
it('Should fixKeys by key w/o re-retrieving, auto-schedule', async () => {
|
|
301
|
+
// WHEN
|
|
302
|
+
handler.setOptions({ skipInteraction: { fixKeysReretrieve: false } });
|
|
303
|
+
const resultFixKeys = await handler.fixKeys('testInstance/testBU', 'automation', [
|
|
304
|
+
'testExisting_automation_fixKey_schedule',
|
|
305
|
+
'testExisting_automation',
|
|
306
|
+
]);
|
|
307
|
+
assert.equal(
|
|
308
|
+
resultFixKeys['testInstance/testBU'].length,
|
|
309
|
+
1,
|
|
310
|
+
'returned number of keys does not correspond to number of expected fixed keys'
|
|
311
|
+
);
|
|
312
|
+
assert.equal(
|
|
313
|
+
resultFixKeys['testInstance/testBU'][0],
|
|
314
|
+
'testExisting_automation_fixedKey_scheduled',
|
|
315
|
+
'returned keys do not correspond to expected fixed keys'
|
|
316
|
+
);
|
|
317
|
+
// THEN
|
|
318
|
+
assert.equal(process.exitCode, false, 'fixKeys should not have thrown an error');
|
|
319
|
+
// confirm updated item
|
|
320
|
+
assert.deepEqual(
|
|
321
|
+
await testUtils.getActualJson(
|
|
322
|
+
'testExisting_automation_fixedKey_scheduled',
|
|
323
|
+
'automation'
|
|
324
|
+
),
|
|
325
|
+
await testUtils.getExpectedJson('9999999', 'automation', 'patch_fixKeys-schedule'),
|
|
326
|
+
'returned metadata was not equal expected for update automation'
|
|
327
|
+
);
|
|
328
|
+
expect(
|
|
329
|
+
file(
|
|
330
|
+
testUtils.getActualDoc(
|
|
331
|
+
'testExisting_automation_fixedKey_scheduled',
|
|
332
|
+
'automation'
|
|
333
|
+
)
|
|
334
|
+
)
|
|
335
|
+
).to.exist;
|
|
336
|
+
// check number of API calls
|
|
337
|
+
assert.equal(
|
|
338
|
+
testUtils.getAPIHistoryLength(),
|
|
339
|
+
29,
|
|
340
|
+
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
|
|
341
|
+
);
|
|
342
|
+
return;
|
|
343
|
+
});
|
|
344
|
+
it('Should fixKeys by key w/o re-retrieving, auto-schedule and then --execute', async () => {
|
|
345
|
+
// WHEN
|
|
346
|
+
handler.setOptions({ skipInteraction: { fixKeysReretrieve: false }, execute: true });
|
|
347
|
+
const resultFixKeys = await handler.fixKeys('testInstance/testBU', 'automation', [
|
|
348
|
+
'testExisting_automation_fixKey_schedule',
|
|
349
|
+
'testExisting_automation',
|
|
350
|
+
]);
|
|
351
|
+
assert.equal(
|
|
352
|
+
resultFixKeys['testInstance/testBU'].length,
|
|
353
|
+
1,
|
|
354
|
+
'returned number of keys does not correspond to number of expected fixed keys'
|
|
355
|
+
);
|
|
356
|
+
assert.equal(
|
|
357
|
+
resultFixKeys['testInstance/testBU'][0],
|
|
358
|
+
'testExisting_automation_fixedKey_scheduled',
|
|
359
|
+
'returned keys do not correspond to expected fixed keys'
|
|
360
|
+
);
|
|
361
|
+
// THEN
|
|
362
|
+
assert.equal(process.exitCode, false, 'fixKeys should not have thrown an error');
|
|
363
|
+
// confirm updated item
|
|
364
|
+
assert.deepEqual(
|
|
365
|
+
await testUtils.getActualJson(
|
|
366
|
+
'testExisting_automation_fixedKey_scheduled',
|
|
367
|
+
'automation'
|
|
368
|
+
),
|
|
369
|
+
await testUtils.getExpectedJson('9999999', 'automation', 'patch_fixKeys-schedule'),
|
|
370
|
+
'returned metadata was not equal expected for update automation'
|
|
371
|
+
);
|
|
372
|
+
expect(
|
|
373
|
+
file(
|
|
374
|
+
testUtils.getActualDoc(
|
|
375
|
+
'testExisting_automation_fixedKey_scheduled',
|
|
376
|
+
'automation'
|
|
377
|
+
)
|
|
378
|
+
)
|
|
379
|
+
).to.exist;
|
|
380
|
+
// check number of API calls
|
|
381
|
+
assert.equal(
|
|
382
|
+
testUtils.getAPIHistoryLength(),
|
|
383
|
+
31,
|
|
384
|
+
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
|
|
385
|
+
);
|
|
386
|
+
return;
|
|
387
|
+
});
|
|
388
|
+
it('Should fixKeys by key w/o re-retrieving, auto-schedule and then --schedule', async () => {
|
|
389
|
+
// WHEN
|
|
390
|
+
handler.setOptions({ skipInteraction: { fixKeysReretrieve: false }, schedule: true });
|
|
391
|
+
const resultFixKeys = await handler.fixKeys('testInstance/testBU', 'automation', [
|
|
392
|
+
'testExisting_automation_fixKey_schedule',
|
|
393
|
+
'testExisting_automation',
|
|
394
|
+
]);
|
|
395
|
+
assert.equal(
|
|
396
|
+
resultFixKeys['testInstance/testBU'].length,
|
|
397
|
+
1,
|
|
398
|
+
'returned number of keys does not correspond to number of expected fixed keys'
|
|
399
|
+
);
|
|
400
|
+
assert.equal(
|
|
401
|
+
resultFixKeys['testInstance/testBU'][0],
|
|
402
|
+
'testExisting_automation_fixedKey_scheduled',
|
|
403
|
+
'returned keys do not correspond to expected fixed keys'
|
|
404
|
+
);
|
|
405
|
+
// THEN
|
|
406
|
+
assert.equal(process.exitCode, false, 'fixKeys should not have thrown an error');
|
|
407
|
+
// confirm updated item
|
|
408
|
+
assert.deepEqual(
|
|
409
|
+
await testUtils.getActualJson(
|
|
410
|
+
'testExisting_automation_fixedKey_scheduled',
|
|
411
|
+
'automation'
|
|
412
|
+
),
|
|
413
|
+
await testUtils.getExpectedJson('9999999', 'automation', 'patch_fixKeys-schedule'),
|
|
414
|
+
'returned metadata was not equal expected for update automation'
|
|
415
|
+
);
|
|
416
|
+
expect(
|
|
417
|
+
file(
|
|
418
|
+
testUtils.getActualDoc(
|
|
419
|
+
'testExisting_automation_fixedKey_scheduled',
|
|
420
|
+
'automation'
|
|
421
|
+
)
|
|
422
|
+
)
|
|
423
|
+
).to.exist;
|
|
424
|
+
// check number of API calls
|
|
425
|
+
assert.equal(
|
|
426
|
+
testUtils.getAPIHistoryLength(),
|
|
427
|
+
32,
|
|
428
|
+
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
|
|
429
|
+
);
|
|
430
|
+
return;
|
|
431
|
+
});
|
|
432
|
+
it('Should fixKeys by key w/o re-retrieving, deploy paused', async () => {
|
|
433
|
+
// WHEN
|
|
434
|
+
handler.setOptions({ skipInteraction: { fixKeysReretrieve: false } });
|
|
435
|
+
const resultFixKeys = await handler.fixKeys('testInstance/testBU', 'automation', [
|
|
436
|
+
'testExisting_automation_fixKey_pause',
|
|
437
|
+
]);
|
|
438
|
+
assert.equal(
|
|
439
|
+
resultFixKeys['testInstance/testBU'].length,
|
|
440
|
+
1,
|
|
441
|
+
'returned number of keys does not correspond to number of expected fixed keys'
|
|
442
|
+
);
|
|
443
|
+
assert.equal(
|
|
444
|
+
resultFixKeys['testInstance/testBU'][0],
|
|
445
|
+
'testExisting_automation_fixedKey_paused',
|
|
446
|
+
'returned keys do not correspond to expected fixed keys'
|
|
447
|
+
);
|
|
448
|
+
// THEN
|
|
449
|
+
assert.equal(process.exitCode, false, 'fixKeys should not have thrown an error');
|
|
450
|
+
// confirm updated item
|
|
451
|
+
assert.deepEqual(
|
|
452
|
+
await testUtils.getActualJson(
|
|
453
|
+
'testExisting_automation_fixedKey_paused',
|
|
454
|
+
'automation'
|
|
455
|
+
),
|
|
456
|
+
await testUtils.getExpectedJson('9999999', 'automation', 'patch_fixKeys-pause'),
|
|
457
|
+
'returned metadata was not equal expected for update automation'
|
|
458
|
+
);
|
|
459
|
+
expect(
|
|
460
|
+
file(
|
|
461
|
+
testUtils.getActualDoc('testExisting_automation_fixedKey_paused', 'automation')
|
|
462
|
+
)
|
|
463
|
+
).to.exist;
|
|
464
|
+
// check number of API calls
|
|
465
|
+
assert.equal(
|
|
466
|
+
testUtils.getAPIHistoryLength(),
|
|
467
|
+
26,
|
|
468
|
+
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
|
|
469
|
+
);
|
|
470
|
+
return;
|
|
471
|
+
});
|
|
472
|
+
it('Should fixKeys by key w/o re-retrieving, deploy paused and then --execute', async () => {
|
|
473
|
+
// WHEN
|
|
474
|
+
handler.setOptions({ skipInteraction: { fixKeysReretrieve: false }, execute: true });
|
|
475
|
+
const resultFixKeys = await handler.fixKeys('testInstance/testBU', 'automation', [
|
|
476
|
+
'testExisting_automation_fixKey_pause',
|
|
477
|
+
'testExisting_automation',
|
|
478
|
+
]);
|
|
479
|
+
assert.equal(
|
|
480
|
+
resultFixKeys['testInstance/testBU'].length,
|
|
481
|
+
1,
|
|
482
|
+
'returned number of keys does not correspond to number of expected fixed keys'
|
|
483
|
+
);
|
|
484
|
+
assert.equal(
|
|
485
|
+
resultFixKeys['testInstance/testBU'][0],
|
|
486
|
+
'testExisting_automation_fixedKey_paused',
|
|
487
|
+
'returned keys do not correspond to expected fixed keys'
|
|
488
|
+
);
|
|
489
|
+
// THEN
|
|
490
|
+
assert.equal(process.exitCode, false, 'fixKeys should not have thrown an error');
|
|
491
|
+
// confirm updated item
|
|
492
|
+
assert.deepEqual(
|
|
493
|
+
await testUtils.getActualJson(
|
|
494
|
+
'testExisting_automation_fixedKey_paused',
|
|
495
|
+
'automation'
|
|
496
|
+
),
|
|
497
|
+
await testUtils.getExpectedJson('9999999', 'automation', 'patch_fixKeys-pause'),
|
|
498
|
+
'returned metadata was not equal expected for update automation'
|
|
499
|
+
);
|
|
500
|
+
expect(
|
|
501
|
+
file(
|
|
502
|
+
testUtils.getActualDoc('testExisting_automation_fixedKey_paused', 'automation')
|
|
503
|
+
)
|
|
504
|
+
).to.exist;
|
|
505
|
+
// check number of API calls
|
|
506
|
+
assert.equal(
|
|
507
|
+
testUtils.getAPIHistoryLength(),
|
|
508
|
+
30,
|
|
509
|
+
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
|
|
510
|
+
);
|
|
511
|
+
return;
|
|
512
|
+
});
|
|
513
|
+
it('Should fixKeys by key w/o re-retrieving, deploy paused and then --schedule', async () => {
|
|
514
|
+
// WHEN
|
|
515
|
+
handler.setOptions({ skipInteraction: { fixKeysReretrieve: false }, schedule: true });
|
|
516
|
+
const resultFixKeys = await handler.fixKeys('testInstance/testBU', 'automation', [
|
|
517
|
+
'testExisting_automation_fixKey_pause',
|
|
518
|
+
'testExisting_automation',
|
|
519
|
+
]);
|
|
520
|
+
assert.equal(
|
|
521
|
+
resultFixKeys['testInstance/testBU'].length,
|
|
522
|
+
1,
|
|
523
|
+
'returned number of keys does not correspond to number of expected fixed keys'
|
|
524
|
+
);
|
|
525
|
+
assert.equal(
|
|
526
|
+
resultFixKeys['testInstance/testBU'][0],
|
|
527
|
+
'testExisting_automation_fixedKey_paused',
|
|
528
|
+
'returned keys do not correspond to expected fixed keys'
|
|
529
|
+
);
|
|
530
|
+
// THEN
|
|
531
|
+
assert.equal(process.exitCode, false, 'fixKeys should not have thrown an error');
|
|
532
|
+
// confirm updated item
|
|
533
|
+
assert.deepEqual(
|
|
534
|
+
await testUtils.getActualJson(
|
|
535
|
+
'testExisting_automation_fixedKey_paused',
|
|
536
|
+
'automation'
|
|
537
|
+
),
|
|
538
|
+
await testUtils.getExpectedJson('9999999', 'automation', 'patch_fixKeys-pause'),
|
|
539
|
+
'returned metadata was not equal expected for update automation'
|
|
540
|
+
);
|
|
541
|
+
expect(
|
|
542
|
+
file(
|
|
543
|
+
testUtils.getActualDoc('testExisting_automation_fixedKey_paused', 'automation')
|
|
544
|
+
)
|
|
545
|
+
).to.exist;
|
|
546
|
+
// check number of API calls
|
|
547
|
+
assert.equal(
|
|
548
|
+
testUtils.getAPIHistoryLength(),
|
|
549
|
+
32,
|
|
550
|
+
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
|
|
551
|
+
);
|
|
552
|
+
return;
|
|
553
|
+
});
|
|
554
|
+
});
|
|
555
|
+
describe('Templating ================', () => {
|
|
556
|
+
it('Should create a automation template via retrieveAsTemplate and build it', async () => {
|
|
557
|
+
// GIVEN there is a template
|
|
558
|
+
const result = await handler.retrieveAsTemplate(
|
|
559
|
+
'testInstance/testBU',
|
|
560
|
+
'automation',
|
|
561
|
+
['testExisting_automation'],
|
|
562
|
+
'testSourceMarket'
|
|
563
|
+
);
|
|
564
|
+
assert.equal(
|
|
565
|
+
process.exitCode,
|
|
566
|
+
false,
|
|
567
|
+
'retrieveAsTemplate should not have thrown an error'
|
|
568
|
+
);
|
|
569
|
+
|
|
570
|
+
// WHEN
|
|
571
|
+
assert.equal(
|
|
572
|
+
result.automation ? Object.keys(result.automation).length : 0,
|
|
573
|
+
1,
|
|
574
|
+
'only one automation expected'
|
|
575
|
+
);
|
|
576
|
+
assert.deepEqual(
|
|
577
|
+
await testUtils.getActualTemplateJson('testExisting_automation', 'automation'),
|
|
578
|
+
await testUtils.getExpectedJson('9999999', 'automation', 'template'),
|
|
579
|
+
'returned template was not equal expected'
|
|
580
|
+
);
|
|
581
|
+
// THEN
|
|
582
|
+
await handler.buildDefinition(
|
|
583
|
+
'testInstance/testBU',
|
|
584
|
+
'automation',
|
|
585
|
+
'testExisting_automation',
|
|
586
|
+
'testTargetMarket'
|
|
587
|
+
);
|
|
588
|
+
assert.equal(
|
|
589
|
+
process.exitCode,
|
|
590
|
+
false,
|
|
591
|
+
'buildDefinition should not have thrown an error'
|
|
592
|
+
);
|
|
593
|
+
assert.deepEqual(
|
|
594
|
+
await testUtils.getActualDeployJson('testTemplated_automation', 'automation'),
|
|
595
|
+
await testUtils.getExpectedJson('9999999', 'automation', 'build'),
|
|
596
|
+
'returned deployment file was not equal expected'
|
|
597
|
+
);
|
|
598
|
+
assert.equal(
|
|
599
|
+
testUtils.getAPIHistoryLength(),
|
|
600
|
+
14,
|
|
601
|
+
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
|
|
602
|
+
);
|
|
603
|
+
return;
|
|
604
|
+
});
|
|
605
|
+
it('Should create a automation template via buildTemplate and build it', async () => {
|
|
606
|
+
// download first before we test buildTemplate
|
|
607
|
+
await handler.retrieve('testInstance/testBU', ['automation']);
|
|
608
|
+
// GIVEN there is a template
|
|
609
|
+
const result = await handler.buildTemplate(
|
|
610
|
+
'testInstance/testBU',
|
|
611
|
+
'automation',
|
|
612
|
+
['testExisting_automation'],
|
|
613
|
+
'testSourceMarket'
|
|
614
|
+
);
|
|
615
|
+
assert.equal(process.exitCode, false, 'buildTemplate should not have thrown an error');
|
|
616
|
+
// WHEN
|
|
617
|
+
assert.equal(
|
|
618
|
+
result.automation ? Object.keys(result.automation).length : 0,
|
|
619
|
+
1,
|
|
620
|
+
'only one automation expected'
|
|
621
|
+
);
|
|
622
|
+
assert.deepEqual(
|
|
623
|
+
await testUtils.getActualTemplateJson('testExisting_automation', 'automation'),
|
|
624
|
+
await testUtils.getExpectedJson('9999999', 'automation', 'template'),
|
|
625
|
+
'returned template was not equal expected'
|
|
626
|
+
);
|
|
627
|
+
// THEN
|
|
628
|
+
await handler.buildDefinition(
|
|
629
|
+
'testInstance/testBU',
|
|
630
|
+
'automation',
|
|
631
|
+
'testExisting_automation',
|
|
632
|
+
'testTargetMarket'
|
|
633
|
+
);
|
|
634
|
+
assert.equal(
|
|
635
|
+
process.exitCode,
|
|
636
|
+
false,
|
|
637
|
+
'buildDefinition should not have thrown an error'
|
|
638
|
+
);
|
|
639
|
+
|
|
640
|
+
assert.deepEqual(
|
|
641
|
+
await testUtils.getActualDeployJson('testTemplated_automation', 'automation'),
|
|
642
|
+
await testUtils.getExpectedJson('9999999', 'automation', 'build'),
|
|
643
|
+
'returned deployment file was not equal expected'
|
|
644
|
+
);
|
|
645
|
+
assert.equal(
|
|
646
|
+
testUtils.getAPIHistoryLength(),
|
|
647
|
+
17,
|
|
648
|
+
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
|
|
649
|
+
);
|
|
650
|
+
return;
|
|
651
|
+
});
|
|
652
|
+
});
|
|
653
|
+
describe('Delete ================', () => {
|
|
654
|
+
it('Should delete the item', async () => {
|
|
655
|
+
// WHEN
|
|
656
|
+
const result = await handler.deleteByKey('testInstance/testBU', 'automation', [
|
|
657
|
+
'testExisting_automation',
|
|
658
|
+
]);
|
|
659
|
+
// THEN
|
|
660
|
+
assert.equal(process.exitCode, false, 'delete should not have thrown an error');
|
|
661
|
+
|
|
662
|
+
assert.equal(result, true, 'should have deleted the item');
|
|
663
|
+
return;
|
|
664
|
+
});
|
|
665
|
+
});
|
|
666
|
+
describe('CI/CD ================', () => {
|
|
667
|
+
it('Should return a list of files based on their type and key', async () => {
|
|
668
|
+
// WHEN
|
|
669
|
+
const fileList = await handler.getFilesToCommit('testInstance/testBU', 'automation', [
|
|
670
|
+
'testExisting_automation',
|
|
671
|
+
]);
|
|
672
|
+
// THEN
|
|
673
|
+
assert.equal(
|
|
674
|
+
process.exitCode,
|
|
675
|
+
false,
|
|
676
|
+
'getFilesToCommit should not have thrown an error'
|
|
677
|
+
);
|
|
678
|
+
assert.equal(fileList.length, 2, 'expected only 2 file paths');
|
|
679
|
+
|
|
680
|
+
assert.equal(
|
|
681
|
+
fileList[0].split('\\').join('/'),
|
|
682
|
+
'retrieve/testInstance/testBU/automation/testExisting_automation.automation-meta.json',
|
|
683
|
+
'wrong JSON path'
|
|
684
|
+
);
|
|
685
|
+
assert.equal(
|
|
686
|
+
fileList[1].split('\\').join('/'),
|
|
687
|
+
'retrieve/testInstance/testBU/automation/testExisting_automation.automation-doc.md',
|
|
688
|
+
'wrong MD path'
|
|
689
|
+
);
|
|
690
|
+
return;
|
|
691
|
+
});
|
|
692
|
+
});
|
|
693
|
+
describe('Schedule ================', () => {
|
|
694
|
+
it('Should schedule an automation by key', async () => {
|
|
695
|
+
const executedKeys = await handler.schedule('testInstance/testBU', 'automation', [
|
|
696
|
+
'testExisting_automation',
|
|
697
|
+
]);
|
|
698
|
+
assert.equal(process.exitCode, false, 'execute should not have thrown an error');
|
|
699
|
+
assert.equal(
|
|
700
|
+
executedKeys['testInstance/testBU']?.length,
|
|
701
|
+
1,
|
|
702
|
+
'returned number of keys does not correspond to number of expected fixed keys'
|
|
703
|
+
);
|
|
704
|
+
assert.equal(
|
|
705
|
+
executedKeys['testInstance/testBU'][0],
|
|
706
|
+
'testExisting_automation',
|
|
707
|
+
'returned keys do not correspond to expected fixed keys'
|
|
708
|
+
);
|
|
709
|
+
return;
|
|
710
|
+
});
|
|
711
|
+
it('Should schedule an automation selected via --like', async () => {
|
|
712
|
+
handler.setOptions({ like: { key: 'testExist%automation' } });
|
|
713
|
+
const executedKeys = await handler.schedule('testInstance/testBU', 'automation');
|
|
714
|
+
assert.equal(process.exitCode, false, 'execute should not have thrown an error');
|
|
715
|
+
assert.equal(
|
|
716
|
+
executedKeys['testInstance/testBU']?.length,
|
|
717
|
+
1,
|
|
718
|
+
'returned number of keys does not correspond to number of expected fixed keys'
|
|
719
|
+
);
|
|
720
|
+
assert.equal(
|
|
721
|
+
executedKeys['testInstance/testBU'][0],
|
|
722
|
+
'testExisting_automation',
|
|
723
|
+
'returned keys do not correspond to expected fixed keys'
|
|
724
|
+
);
|
|
725
|
+
return;
|
|
726
|
+
});
|
|
727
|
+
it('Should not schedule executing an automation because key and --like was specified', async () => {
|
|
728
|
+
handler.setOptions({ like: { key: 'testExisting%' } });
|
|
729
|
+
const executedKeys = await handler.schedule('testInstance/testBU', 'automation', [
|
|
730
|
+
'testExisting_automation',
|
|
731
|
+
]);
|
|
732
|
+
assert.equal(process.exitCode, true, 'execute should have thrown an error');
|
|
733
|
+
assert.equal(
|
|
734
|
+
Object.keys(executedKeys).length,
|
|
735
|
+
0,
|
|
736
|
+
'automation was not supposed to be executed'
|
|
737
|
+
);
|
|
738
|
+
return;
|
|
739
|
+
});
|
|
740
|
+
});
|
|
741
|
+
describe('Execute ================', () => {
|
|
742
|
+
it('Should execute --schedule an automation by key', async () => {
|
|
743
|
+
handler.setOptions({ schedule: true });
|
|
744
|
+
const executedKeys = await handler.execute('testInstance/testBU', 'automation', [
|
|
745
|
+
'testExisting_automation',
|
|
746
|
+
]);
|
|
747
|
+
assert.equal(process.exitCode, false, 'execute should not have thrown an error');
|
|
748
|
+
assert.equal(
|
|
749
|
+
executedKeys['testInstance/testBU']?.length,
|
|
750
|
+
1,
|
|
751
|
+
'returned number of keys does not correspond to number of expected fixed keys'
|
|
752
|
+
);
|
|
753
|
+
assert.equal(
|
|
754
|
+
executedKeys['testInstance/testBU'][0],
|
|
755
|
+
'testExisting_automation',
|
|
756
|
+
'returned keys do not correspond to expected fixed keys'
|
|
757
|
+
);
|
|
758
|
+
return;
|
|
759
|
+
});
|
|
760
|
+
it('Should execute --schedule an automation selected via --like', async () => {
|
|
761
|
+
handler.setOptions({ like: { key: 'testExist%automation' }, schedule: true });
|
|
762
|
+
const executedKeys = await handler.execute('testInstance/testBU', 'automation');
|
|
763
|
+
assert.equal(process.exitCode, false, 'execute should not have thrown an error');
|
|
764
|
+
assert.equal(
|
|
765
|
+
executedKeys['testInstance/testBU']?.length,
|
|
766
|
+
1,
|
|
767
|
+
'returned number of keys does not correspond to number of expected fixed keys'
|
|
768
|
+
);
|
|
769
|
+
assert.equal(
|
|
770
|
+
executedKeys['testInstance/testBU'][0],
|
|
771
|
+
'testExisting_automation',
|
|
772
|
+
'returned keys do not correspond to expected fixed keys'
|
|
773
|
+
);
|
|
774
|
+
return;
|
|
775
|
+
});
|
|
776
|
+
it('Should not execute --schedule executing an automation because key and --like was specified', async () => {
|
|
777
|
+
handler.setOptions({ like: { key: 'testExisting%' }, schedule: true });
|
|
778
|
+
const executedKeys = await handler.execute('testInstance/testBU', 'automation', [
|
|
779
|
+
'testExisting_automation',
|
|
780
|
+
]);
|
|
781
|
+
assert.equal(process.exitCode, true, 'execute should have thrown an error');
|
|
782
|
+
assert.equal(
|
|
783
|
+
Object.keys(executedKeys).length,
|
|
784
|
+
0,
|
|
785
|
+
'automation was not supposed to be executed'
|
|
786
|
+
);
|
|
787
|
+
return;
|
|
788
|
+
});
|
|
789
|
+
it('Should runOnce an automation by key', async () => {
|
|
790
|
+
const executedKeys = await handler.execute('testInstance/testBU', 'automation', [
|
|
791
|
+
'testExisting_automation',
|
|
792
|
+
]);
|
|
793
|
+
assert.equal(process.exitCode, false, 'execute should not have thrown an error');
|
|
794
|
+
assert.equal(
|
|
795
|
+
executedKeys['testInstance/testBU']?.length,
|
|
796
|
+
1,
|
|
797
|
+
'automation was supposed to be executed'
|
|
798
|
+
);
|
|
799
|
+
assert.equal(
|
|
800
|
+
executedKeys['testInstance/testBU'][0],
|
|
801
|
+
'testExisting_automation',
|
|
802
|
+
'returned keys do not correspond to expected fixed keys'
|
|
803
|
+
);
|
|
804
|
+
return;
|
|
805
|
+
});
|
|
806
|
+
it('Should runOnce an automation selected via --like', async () => {
|
|
807
|
+
handler.setOptions({ like: { key: 'testExist%automation' } });
|
|
808
|
+
const executedKeys = await handler.execute('testInstance/testBU', 'automation');
|
|
809
|
+
assert.equal(process.exitCode, false, 'execute should not have thrown an error');
|
|
810
|
+
assert.equal(
|
|
811
|
+
executedKeys['testInstance/testBU']?.length,
|
|
812
|
+
1,
|
|
813
|
+
'automation was supposed to be executed'
|
|
814
|
+
);
|
|
815
|
+
assert.equal(
|
|
816
|
+
executedKeys['testInstance/testBU'][0],
|
|
817
|
+
'testExisting_automation',
|
|
818
|
+
'returned keys do not correspond to expected fixed keys'
|
|
819
|
+
);
|
|
820
|
+
|
|
821
|
+
return;
|
|
822
|
+
});
|
|
823
|
+
it('Should not runOnce executing an automation because key and --like was specified', async () => {
|
|
824
|
+
handler.setOptions({ like: { key: 'testExisting%' } });
|
|
825
|
+
const executedKeys = await handler.execute('testInstance/testBU', 'automation', [
|
|
826
|
+
'testExisting_automation',
|
|
827
|
+
]);
|
|
828
|
+
assert.equal(process.exitCode, true, 'execute should have thrown an error');
|
|
829
|
+
assert.equal(
|
|
830
|
+
Object.keys(executedKeys).length,
|
|
831
|
+
0,
|
|
832
|
+
'automation was not supposed to be executed'
|
|
833
|
+
);
|
|
834
|
+
|
|
835
|
+
return;
|
|
836
|
+
});
|
|
837
|
+
});
|
|
838
|
+
describe('Pause ================', () => {
|
|
839
|
+
it('Should pause a automation by key', async () => {
|
|
840
|
+
const pausedKeys = await handler.pause('testInstance/testBU', 'automation', [
|
|
841
|
+
'testExisting_automation_pause',
|
|
842
|
+
]);
|
|
843
|
+
assert.equal(process.exitCode, false, 'pause should not have thrown an error');
|
|
844
|
+
assert.equal(
|
|
845
|
+
pausedKeys['testInstance/testBU']?.length,
|
|
846
|
+
1,
|
|
847
|
+
'returned number of keys does not correspond to number of expected fixed keys'
|
|
848
|
+
);
|
|
849
|
+
assert.equal(
|
|
850
|
+
pausedKeys['testInstance/testBU'][0],
|
|
851
|
+
'testExisting_automation_pause',
|
|
852
|
+
'returned keys do not correspond to expected fixed keys'
|
|
853
|
+
);
|
|
854
|
+
return;
|
|
855
|
+
});
|
|
856
|
+
it('Should pause a automation selected via --like', async () => {
|
|
857
|
+
handler.setOptions({ like: { key: 'testExisting_a%n_pause' } });
|
|
858
|
+
const pausedKeys = await handler.pause('testInstance/testBU', 'automation');
|
|
859
|
+
assert.equal(process.exitCode, false, 'pause should not have thrown an error');
|
|
860
|
+
assert.equal(
|
|
861
|
+
pausedKeys['testInstance/testBU']?.length,
|
|
862
|
+
1,
|
|
863
|
+
'returned number of keys does not correspond to number of expected fixed keys'
|
|
864
|
+
);
|
|
865
|
+
assert.equal(
|
|
866
|
+
pausedKeys['testInstance/testBU'][0],
|
|
867
|
+
'testExisting_automation_pause',
|
|
868
|
+
'returned keys do not correspond to expected fixed keys'
|
|
869
|
+
);
|
|
870
|
+
return;
|
|
871
|
+
});
|
|
872
|
+
it('Should not pause automation because key and --like was specified', async () => {
|
|
873
|
+
handler.setOptions({ like: { key: 'testExisting_a%n_pause' } });
|
|
874
|
+
const pausedKeys = await handler.pause('testInstance/testBU', 'automation', [
|
|
875
|
+
'testExisting_automation_pause',
|
|
876
|
+
]);
|
|
877
|
+
assert.equal(process.exitCode, true, 'pause should have thrown an error');
|
|
878
|
+
assert.equal(
|
|
879
|
+
Object.keys(pausedKeys).length,
|
|
880
|
+
0,
|
|
881
|
+
'returned number of keys does not correspond to number of expected fixed keys'
|
|
882
|
+
);
|
|
883
|
+
return;
|
|
884
|
+
});
|
|
885
|
+
});
|
|
886
|
+
});
|