diff --git a/.vscode/extensions.json b/.vscode/extensions.json
index 1228879f3..a71f41ad1 100644
--- a/.vscode/extensions.json
+++ b/.vscode/extensions.json
@@ -15,6 +15,10 @@
"editorconfig.editorconfig",
"esbenp.prettier-vscode",
+ // mcdev tests
+ "hbenl.vscode-mocha-test-adapter",
+ "IBM.output-colorizer",
+
// Markdown / Readme.md
"joernberkefeld.markdown-preview-bitbucket-innersource"
]
diff --git a/boilerplate/files/.vscode/extensions.json b/boilerplate/files/.vscode/extensions.json
index 6754c712a..cfc600e5c 100644
--- a/boilerplate/files/.vscode/extensions.json
+++ b/boilerplate/files/.vscode/extensions.json
@@ -4,9 +4,6 @@
// List of extensions which should be recommended for users of this workspace.
"recommendations": [
- // mcdev vscode extension
- "IBM.output-colorizer",
-
// collaboration
"gruntfuggly.todo-tree",
"aaron-bond.better-comments",
diff --git a/docs/dist/documentation.md b/docs/dist/documentation.md
index 00debb980..8a2189b07 100644
--- a/docs/dist/documentation.md
+++ b/docs/dist/documentation.md
@@ -216,7 +216,7 @@ Provides default functionality that can be overwritten by child metadata type cl
Automation.(metadataMap, key) ⇒ Promise.<void>
helper for postDeployTasks
-Automation.(metadataMap, originalMetadataMap, key) ⇒ Promise.<{key:string, response:object}>
+Automation.(metadataMap, originalMetadataMap, key, [oldKey]) ⇒ Promise.<{key:string, response:object}>
helper for postDeployTasks
getUserName(userList, item, fieldname) ⇒ string
@@ -8526,7 +8526,7 @@ helper for [postDeployTasks](#Automation.postDeployTasks)
-## Automation.(metadataMap, originalMetadataMap, key) ⇒ Promise.<{key:string, response:object}>
+## Automation.(metadataMap, originalMetadataMap, key, [oldKey]) ⇒ Promise.<{key:string, response:object}>
helper for [postDeployTasks](#Automation.postDeployTasks)
**Kind**: global function
@@ -8537,6 +8537,7 @@ helper for [postDeployTasks](#Automation.postDeployTasks)
| metadataMap | TYPE.AutomationMap
| metadata mapped by their keyField |
| originalMetadataMap | TYPE.AutomationMap
| metadata to be updated (contains additioanl fields) |
| key | string
| current customer key |
+| [oldKey] | string
| old customer key before fixKey / changeKeyValue / changeKeyField |
diff --git a/lib/cli.js b/lib/cli.js
index b12914767..8c198cf97 100644
--- a/lib/cli.js
+++ b/lib/cli.js
@@ -536,6 +536,18 @@ yargs
group: 'Options for fixKeys:',
describe:
'filter metadata components (can include % as wildcard or _ for a single character)',
+ })
+ .option('execute', {
+ type: 'boolean',
+ group: 'Options for fixKeys:',
+ describe:
+ 'optional: executes item after deploy; this will run the item once immediately',
+ })
+ .option('schedule', {
+ type: 'boolean',
+ group: 'Options for fixKeys:',
+ describe:
+ 'optionally start existing schedule instead of running item once immediately (only works for automations)',
});
},
handler: (argv) => {
diff --git a/lib/metadataTypes/Automation.js b/lib/metadataTypes/Automation.js
index 80c05584f..d68105298 100644
--- a/lib/metadataTypes/Automation.js
+++ b/lib/metadataTypes/Automation.js
@@ -383,8 +383,12 @@ class Automation extends MetadataType {
// Do nothing for now
}
if (metadata.steps) {
+ let i = 0;
+
for (const step of metadata.steps) {
- const stepNumber = step.stepNumber || step.step;
+ i++;
+
+ const stepNumber = step.stepNumber || step.step || i;
delete step.stepNumber;
delete step.step;
@@ -491,12 +495,12 @@ class Automation extends MetadataType {
// schedule
const results = await this.retrieve(undefined, undefined, undefined, key);
if (Object.keys(results.metadata).length) {
- for (const key of Object.keys(results.metadata)) {
- if (this.#isValidSchedule(results.metadata[key])) {
- metadataMap[key] = results.metadata[key];
+ for (const resultKey of Object.keys(results.metadata)) {
+ if (this.#isValidSchedule(results.metadata[resultKey])) {
+ metadataMap[resultKey] = results.metadata[resultKey];
} else {
Util.logger.error(
- ` - skipping ${this.definition.type} ${results.metadata[key].name}: no valid schedule settings found.`
+ ` - skipping ${this.definition.type} ${results.metadata[resultKey].name}: no valid schedule settings found.`
);
}
}
@@ -878,6 +882,16 @@ class Automation extends MetadataType {
}
return deployable;
}
+ /**
+ * helper for {@link MetadataType.updateREST} and {@link MetadataType.updateSOAP} that removes old files after the key was changed
+ *
+ * @private
+ * @param {TYPE.MetadataTypeItem} metadataEntry a single metadata Entry
+ * @returns {void}
+ */
+ static async _postChangeKeyTasks(metadataEntry) {
+ super._postChangeKeyTasks(metadataEntry, true);
+ }
/**
* Gets executed after deployment of metadata type
@@ -888,21 +902,25 @@ class Automation extends MetadataType {
*/
static async postDeployTasks(metadataMap, originalMetadataMap) {
for (const key in metadataMap) {
- if (!metadataMap[key].type) {
+ const item = metadataMap[key];
+
+ const oldKey = Util.changedKeysMap?.[this.definition.type]?.[key] || key;
+ delete Util.changedKeysMap?.[this.definition.type]?.[key];
+
+ if (!item.type) {
// create response does not return the type attribute
- const scheduleHelper =
- metadataMap[key].schedule || metadataMap[key].startSource.schedule;
+ const scheduleHelper = item.schedule || item.startSource.schedule;
// el.type
- metadataMap[key].type = scheduleHelper
+ item.type = scheduleHelper
? 'scheduled'
- : metadataMap[key].fileTrigger
+ : item.fileTrigger
? 'triggered'
: undefined;
// el.schedule.timezoneName
- if (metadataMap[key].type === 'scheduled') {
+ if (item.type === 'scheduled') {
// not existing for triggered automations
scheduleHelper.timezoneName ||= Util.inverseGet(
this.definition.timeZoneMapping,
@@ -911,21 +929,17 @@ class Automation extends MetadataType {
}
// el.status
- metadataMap[key].status ||= Util.inverseGet(
- this.definition.statusMapping,
- metadataMap[key].statusId
- );
+ item.status ||= Util.inverseGet(this.definition.statusMapping, item.statusId);
}
// need to put schedule on here if status is scheduled
- await Automation.#scheduleAutomation(metadataMap, originalMetadataMap, key);
+ await Automation.#scheduleAutomation(metadataMap, originalMetadataMap, key, oldKey);
// need to update notifications separately if there are any
await Automation.#updateNotificationInfoREST(metadataMap, key);
// rewrite upsert to retrieve fields
- const metadata = metadataMap[key];
- if (metadata.steps) {
- for (const step of metadata.steps) {
+ if (item.steps) {
+ for (const step of item.steps) {
step.name = step.annotation;
delete step.annotation;
}
@@ -989,19 +1003,21 @@ class Automation extends MetadataType {
* @param {TYPE.AutomationMap} metadataMap metadata mapped by their keyField
* @param {TYPE.AutomationMap} originalMetadataMap metadata to be updated (contains additioanl fields)
* @param {string} key current customer key
+ * @param {string} [oldKey] old customer key before fixKey / changeKeyValue / changeKeyField
* @returns {Promise.<{key:string, response:object}>} metadata key and API response
*/
- static async #scheduleAutomation(metadataMap, originalMetadataMap, key) {
+ static async #scheduleAutomation(metadataMap, originalMetadataMap, key, oldKey) {
let response = null;
- if (originalMetadataMap[key]?.type === 'scheduled') {
+ oldKey ||= key;
+ if (originalMetadataMap[oldKey]?.type === 'scheduled') {
// Starting Source == 'Schedule': Try starting the automation
- if (originalMetadataMap[key].status === 'Scheduled') {
+ if (originalMetadataMap[oldKey].status === 'Scheduled') {
let schedule = null;
try {
- schedule = this._buildSchedule(originalMetadataMap[key].schedule);
+ schedule = this._buildSchedule(originalMetadataMap[oldKey].schedule);
} catch (ex) {
Util.logger.error(
- `- Could not create schedule for automation '${originalMetadataMap[key].name}' to start it: ${ex.message}`
+ `- Could not create schedule for automation '${originalMetadataMap[oldKey].name}' to start it: ${ex.message}`
);
}
if (schedule !== null) {
@@ -1033,7 +1049,7 @@ class Automation extends MetadataType {
(schedule_interval > 1 ? 's' : ''));
Util.logger.warn(
` - scheduled automation '${
- originalMetadataMap[key].name
+ originalMetadataMap[oldKey].name
}' deployed as Active: runs every ${intervalString} starting ${
schedule_StartDateTime.split('T').join(' ').split('.')[0]
} ${schedule_timezoneString}`
@@ -1048,7 +1064,7 @@ class Automation extends MetadataType {
} else {
Util.logger.info(
Util.getGrayMsg(
- ` - scheduled automation '${originalMetadataMap[key].name}' deployed as Paused`
+ ` - scheduled automation '${originalMetadataMap[oldKey].name}' deployed as Paused`
)
);
}
diff --git a/lib/util/util.js b/lib/util/util.js
index 5dc6cc1fe..685fb079f 100644
--- a/lib/util/util.js
+++ b/lib/util/util.js
@@ -131,8 +131,8 @@ const Util = {
* @returns {void}
*/
signalFatalError() {
- Util.logger.debug('Util.signalFataError() sets process.exitCode = 1');
- process.exitCode = 1;
+ Util.logger.debug('Util.signalFataError() sets process.exitCode = 1 unless already set');
+ process.exitCode ||= 1;
},
/**
* SFMC accepts multiple true values for Boolean attributes for which we are checking here.
diff --git a/test/resourceFactory.js b/test/resourceFactory.js
index 4893db342..e782a98a5 100644
--- a/test/resourceFactory.js
+++ b/test/resourceFactory.js
@@ -1,9 +1,36 @@
const fs = require('fs-extra');
const path = require('node:path');
const { XMLParser } = require('fast-xml-parser');
-const { color } = require('../lib/util/util');
+const Util = require('../lib/util/util');
const parser = new XMLParser();
const attributeParser = new XMLParser({ ignoreAttributes: false });
+let color;
+
+/* eslint-disable unicorn/prefer-ternary */
+if (
+ process.env.VSCODE_AMD_ENTRYPOINT === 'vs/workbench/api/node/extensionHostProcess' ||
+ process.env.VSCODE_CRASH_REPORTER_PROCESS_TYPE === 'extensionHost'
+) {
+ // when we execute the test in a VSCode extension host, we don't want CLI color codes.
+ color = new Proxy(
+ {},
+ {
+ /**
+ * catch-all for color
+ *
+ * @returns {string} empty string
+ */
+ get() {
+ return '';
+ },
+ }
+ );
+} else {
+ // test is executed directly in a command prompt. Use colors.
+ color = Util.color;
+}
+/* eslint-enable unicorn/prefer-ternary */
+
/**
* gets mock SOAP metadata for responding
*
@@ -26,7 +53,7 @@ exports.loadSOAPRecords = async (mcdevAction, type, mid, filter) => {
if (filterPath) {
/* eslint-disable no-console */
console.log(
- `${color.bgYellow}${color.fgBlack}test-warning${
+ `${color.bgYellow}${color.fgBlack}TEST-WARNING${
color.reset
}: You are loading your reponse from ${
testPath + '-response.xml'
@@ -42,7 +69,7 @@ exports.loadSOAPRecords = async (mcdevAction, type, mid, filter) => {
}
/* eslint-disable no-console */
console.log(
- `${color.bgRed}${color.fgBlack}test-error${color.reset}: Please create file ${
+ `${color.bgRed}${color.fgBlack}TEST-ERROR${color.reset}: Please create file ${
filterPath ? testPath + filterPath + '-response.xml or ' : ''
}${testPath + '-response.xml'}`
);
@@ -228,7 +255,7 @@ exports.handleRESTRequest = async (config) => {
} else {
/* eslint-disable no-console */
console.log(
- `${color.bgRed}${color.fgBlack}test-error${color.reset}: Please create file ${testPath}.json/.txt`
+ `${color.bgRed}${color.fgBlack}TEST-ERROR${color.reset}: Please create file ${testPath}.json/.txt`
);
/* eslint-enable no-console */
process.exitCode = 404;
diff --git a/test/resources/9999999/automation/patch_fixKeys-pause-expected.json b/test/resources/9999999/automation/patch_fixKeys-pause-expected.json
new file mode 100644
index 000000000..67ad413f2
--- /dev/null
+++ b/test/resources/9999999/automation/patch_fixKeys-pause-expected.json
@@ -0,0 +1,44 @@
+{
+ "description": "testing fixKey on an a paused automation",
+ "key": "testExisting_automation_fixedKey_paused",
+ "name": "testExisting_automation_fixedKey_paused",
+ "r__folder_Path": "my automations",
+ "schedule": {
+ "endDate": "2022-07-30T00:00:00",
+ "icalRecur": "FREQ=DAILY;COUNT=1;INTERVAL=1",
+ "startDate": "2022-07-30T00:00:00",
+ "timezoneName": "W. Europe Standard Time"
+ },
+ "status": "PausedSchedule",
+ "steps": [
+ {
+ "activities": [
+ {
+ "name": "testExisting_dataExtract",
+ "r__type": "dataExtract"
+ },
+ {
+ "name": "testExisting_emailSend",
+ "r__type": "emailSend"
+ },
+ {
+ "name": "testExisting_fileTransfer",
+ "r__type": "fileTransfer"
+ },
+ {
+ "name": "testExisting_importFile",
+ "r__type": "importFile"
+ },
+ {
+ "name": "testExisting_query",
+ "r__type": "query"
+ },
+ {
+ "name": "testExisting_script",
+ "r__type": "script"
+ }
+ ]
+ }
+ ],
+ "type": "scheduled"
+}
diff --git a/test/resources/9999999/automation/patch_fixKeys-schedule-expected.json b/test/resources/9999999/automation/patch_fixKeys-schedule-expected.json
new file mode 100644
index 000000000..7ac22ba98
--- /dev/null
+++ b/test/resources/9999999/automation/patch_fixKeys-schedule-expected.json
@@ -0,0 +1,44 @@
+{
+ "description": "testing fixKey on an a scheduled automation",
+ "key": "testExisting_automation_fixedKey_scheduled",
+ "name": "testExisting_automation_fixedKey_scheduled",
+ "r__folder_Path": "my automations",
+ "schedule": {
+ "endDate": "2022-07-30T00:00:00",
+ "icalRecur": "FREQ=DAILY;COUNT=1;INTERVAL=1",
+ "startDate": "2022-07-30T00:00:00",
+ "timezoneName": "W. Europe Standard Time"
+ },
+ "status": "Scheduled",
+ "steps": [
+ {
+ "activities": [
+ {
+ "name": "testExisting_dataExtract",
+ "r__type": "dataExtract"
+ },
+ {
+ "name": "testExisting_emailSend",
+ "r__type": "emailSend"
+ },
+ {
+ "name": "testExisting_fileTransfer",
+ "r__type": "fileTransfer"
+ },
+ {
+ "name": "testExisting_importFile",
+ "r__type": "importFile"
+ },
+ {
+ "name": "testExisting_query",
+ "r__type": "query"
+ },
+ {
+ "name": "testExisting_script",
+ "r__type": "script"
+ }
+ ]
+ }
+ ],
+ "type": "scheduled"
+}
diff --git a/test/resources/9999999/automation/perform-08afb0e2-b00a-4c88-fixKey_pause-response.xml b/test/resources/9999999/automation/perform-08afb0e2-b00a-4c88-fixKey_pause-response.xml
new file mode 100644
index 000000000..d301c7cee
--- /dev/null
+++ b/test/resources/9999999/automation/perform-08afb0e2-b00a-4c88-fixKey_pause-response.xml
@@ -0,0 +1,42 @@
+
+
+
+ PerformResponse
+ urn:uuid:cc45bb83-15a3-4a82-ba48-47ac4fb13000
+ urn:uuid:29986848-a0c3-4f3b-bf5a-91151f784449
+ http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
+
+
+ 2023-06-02T13:41:30Z
+ 2023-06-02T13:46:30Z
+
+
+
+
+
+
+
+ OK
+ Performed Activity
+
+
+
+ OK
+
+ 898702fc-a432-4176-8130-5d6dd5ad9ca6
+
+
+
diff --git a/test/resources/9999999/automation/perform-08afb0e2-b00a-4c88-fixKey_schedule-response.xml b/test/resources/9999999/automation/perform-08afb0e2-b00a-4c88-fixKey_schedule-response.xml
new file mode 100644
index 000000000..c1c9e7685
--- /dev/null
+++ b/test/resources/9999999/automation/perform-08afb0e2-b00a-4c88-fixKey_schedule-response.xml
@@ -0,0 +1,42 @@
+
+
+
+ PerformResponse
+ urn:uuid:cc45bb83-15a3-4a82-ba48-47ac4fb13000
+ urn:uuid:29986848-a0c3-4f3b-bf5a-91151f784449
+ http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
+
+
+ 2023-06-02T13:41:30Z
+ 2023-06-02T13:46:30Z
+
+
+
+
+
+
+
+ OK
+ Performed Activity
+
+
+
+ OK
+
+ 898702fc-a432-4176-8130-5d6dd5ad9ca6
+
+
+
diff --git a/test/resources/9999999/automation/perform-a8afb0e2-b00a-4c88-ad2e-1f7f8788c560-response.xml b/test/resources/9999999/automation/perform-a8afb0e2-b00a-4c88-ad2e-1f7f8788c560-response.xml
new file mode 100644
index 000000000..597d3e3a8
--- /dev/null
+++ b/test/resources/9999999/automation/perform-a8afb0e2-b00a-4c88-ad2e-1f7f8788c560-response.xml
@@ -0,0 +1,42 @@
+
+
+
+ PerformResponse
+ urn:uuid:cc45bb83-15a3-4a82-ba48-47ac4fb13000
+ urn:uuid:29986848-a0c3-4f3b-bf5a-91151f784449
+ http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
+
+
+ 2023-06-02T13:41:30Z
+ 2023-06-02T13:46:30Z
+
+
+
+
+
+
+
+ OK
+ Performed Activity
+
+
+
+ OK
+
+ 898702fc-a432-4176-8130-5d6dd5ad9ca6
+
+
+
diff --git a/test/resources/9999999/automation/schedule-08afb0e2-b00a-4c88-fixKey_pause-response.xml b/test/resources/9999999/automation/schedule-08afb0e2-b00a-4c88-fixKey_pause-response.xml
new file mode 100644
index 000000000..06deeccde
--- /dev/null
+++ b/test/resources/9999999/automation/schedule-08afb0e2-b00a-4c88-fixKey_pause-response.xml
@@ -0,0 +1,52 @@
+
+
+
+ ScheduleResponse
+ urn:uuid:b58a82d9-a251-4be4-b50c-bd300d71601d
+ urn:uuid:9d3dbeb3-68b7-4f0a-b0af-04855dc0fd1e
+ http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
+
+
+ 2023-07-05T10:29:58Z
+ 2023-07-05T10:34:58Z
+
+
+
+
+
+
+
+ OK
+ Program scheduled.
+ 3a677ca8-5423-4d59-a1bb-c5fbe1c87197
+
+
+
+
+ OK
+
+ cfe97488-3c5e-49a9-b338-c0e9f6b6f684
+
+
+
diff --git a/test/resources/9999999/automation/schedule-08afb0e2-b00a-4c88-fixKey_schedule-response.xml b/test/resources/9999999/automation/schedule-08afb0e2-b00a-4c88-fixKey_schedule-response.xml
new file mode 100644
index 000000000..06deeccde
--- /dev/null
+++ b/test/resources/9999999/automation/schedule-08afb0e2-b00a-4c88-fixKey_schedule-response.xml
@@ -0,0 +1,52 @@
+
+
+
+ ScheduleResponse
+ urn:uuid:b58a82d9-a251-4be4-b50c-bd300d71601d
+ urn:uuid:9d3dbeb3-68b7-4f0a-b0af-04855dc0fd1e
+ http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
+
+
+ 2023-07-05T10:29:58Z
+ 2023-07-05T10:34:58Z
+
+
+
+
+
+
+
+ OK
+ Program scheduled.
+ 3a677ca8-5423-4d59-a1bb-c5fbe1c87197
+
+
+
+
+ OK
+
+ cfe97488-3c5e-49a9-b338-c0e9f6b6f684
+
+
+
diff --git a/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-pause/patch-response.json b/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-pause/patch-response.json
new file mode 100644
index 000000000..2454567e8
--- /dev/null
+++ b/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-pause/patch-response.json
@@ -0,0 +1,85 @@
+{
+ "legacyId": "RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow-PAUSED",
+ "name": "testExisting_automation_pause",
+ "description": "updated on deploy",
+ "key": "testExisting_automation_pause",
+ "typeId": 1,
+ "type": "scheduled",
+ "statusId": 4,
+ "status": "Scheduled",
+ "schedule": {
+ "id": "b393aa6c-a4a8-4c0f-a148-9250258a7339",
+ "typeId": 3,
+ "startDate": "2022-07-30T00:00:00",
+ "endDate": "2022-07-30T00:00:00",
+ "scheduledTime": "0001-01-01T07:00:00",
+ "rangeTypeId": 0,
+ "occurrences": 1,
+ "pattern": "01",
+ "icalRecur": "FREQ=DAILY;COUNT=1;INTERVAL=1",
+ "timezoneName": "W. Europe Standard Time",
+ "scheduleStatus": "scheduled",
+ "timezoneId": 5
+ },
+ "steps": [
+ {
+ "activities": [
+ {
+ "id": "8081a992-a27d-4a43-984a-d60114ea1025",
+ "name": "testExisting_dataExtract",
+ "activityObjectId": "56c5370a-f988-4f36-b0ee-0f876573f6d7",
+ "objectTypeId": 73,
+ "displayOrder": 1
+ },
+ {
+ "id": "d3774dc2-a271-4a44-8cbe-f630a6d6545e",
+ "name": "testExisting_emailSend",
+ "activityObjectId": "9b1c7bf9-4964-ed11-b849-48df37d1de8b",
+ "objectTypeId": 42,
+ "displayOrder": 2
+ },
+ {
+ "id": "2c77fc42-85eb-4611-98f9-223d29d89d72",
+ "name": "testExisting_fileTransfer",
+ "activityObjectId": "72c328ac-f5b0-4e37-91d3-a775666f15a6",
+ "objectTypeId": 53,
+ "displayOrder": 3
+ },
+ {
+ "id": "298b2794-28cb-4c70-b7ad-58b2c8cf48f7",
+ "name": "testExisting_importFile",
+ "activityObjectId": "9d16f42c-2260-ed11-b849-48df37d1de8b",
+ "objectTypeId": 43,
+ "displayOrder": 4,
+ "targetDataExtensions": [
+ {
+ "id": "21711373-72c1-ec11-b83b-48df37d1deb7",
+ "name": "testExisting_dataExtension",
+ "key": "testExisting_dataExtension",
+ "description": "bla bla",
+ "rowCount": 0
+ }
+ ]
+ },
+ {
+ "id": "e3774dc2-a271-4a44-8cbe-f630a6d6545e",
+ "name": "testExisting_query_WRONG_NAME",
+ "activityObjectId": "549f0568-607c-4940-afef-437965094dat",
+ "objectTypeId": 300,
+ "displayOrder": 5
+ },
+ {
+ "id": "g3774dc2-a271-4a44-8cbe-f630a6d6545e",
+ "name": "testExisting_script",
+ "activityObjectId": "39f6a488-20eb-4ba0-b0b9-023725b574e4",
+ "objectTypeId": 423,
+ "displayOrder": 6
+ }
+ ],
+ "annotation": "",
+ "stepNumber": 0
+ }
+ ],
+ "categoryId": 290937,
+ "id": "08afb0e2-b00a-4c88-ad2e-1f7f8788c560"
+}
diff --git a/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-fixKey_pause/get-response.json b/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-fixKey_pause/get-response.json
new file mode 100644
index 000000000..17e4c6c2e
--- /dev/null
+++ b/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-fixKey_pause/get-response.json
@@ -0,0 +1,85 @@
+{
+ "id": "08afb0e2-b00a-4c88-fixKey_pause",
+ "name": "testExisting_automation_fixedKey_paused",
+ "description": "testing fixKey on an a paused automation",
+ "key": "testExisting_automation_fixKey_pause",
+ "typeId": 1,
+ "type": "scheduled",
+ "statusId": 4,
+ "status": "PausedSchedule",
+ "categoryId": 290937,
+ "schedule": {
+ "id": "b393aa6c-a4a8-4c0f-a148-9250258a7339",
+ "typeId": 3,
+ "startDate": "2022-07-30T00:00:00",
+ "endDate": "2022-07-30T00:00:00",
+ "scheduledTime": "0001-01-01T07:00:00",
+ "rangeTypeId": 0,
+ "occurrences": 1,
+ "pattern": "01",
+ "icalRecur": "FREQ=DAILY;COUNT=1;INTERVAL=1",
+ "timezoneName": "W. Europe Standard Time",
+ "scheduleStatus": "paused",
+ "timezoneId": 5
+ },
+ "steps": [
+ {
+ "id": "13fda077-0e82-4936-b936-a36b0997fc44",
+ "name": "",
+ "step": 1,
+ "activities": [
+ {
+ "id": "8081a992-a27d-4a43-984a-d60114ea1025",
+ "name": "testExisting_dataExtract",
+ "activityObjectId": "56c5370a-f988-4f36-b0ee-0f876573f6d7",
+ "objectTypeId": 73,
+ "displayOrder": 1
+ },
+ {
+ "id": "d3774dc2-a271-4a44-8cbe-f630a6d6545e",
+ "name": "testExisting_emailSend",
+ "activityObjectId": "9b1c7bf9-4964-ed11-b849-48df37d1de8b",
+ "objectTypeId": 42,
+ "displayOrder": 2
+ },
+ {
+ "id": "2c77fc42-85eb-4611-98f9-223d29d89d72",
+ "name": "testExisting_fileTransfer",
+ "activityObjectId": "72c328ac-f5b0-4e37-91d3-a775666f15a6",
+ "objectTypeId": 53,
+ "displayOrder": 3
+ },
+ {
+ "id": "298b2794-28cb-4c70-b7ad-58b2c8cf48f7",
+ "name": "testExisting_importFile",
+ "activityObjectId": "9d16f42c-2260-ed11-b849-48df37d1de8b",
+ "objectTypeId": 43,
+ "displayOrder": 4,
+ "targetDataExtensions": [
+ {
+ "id": "21711373-72c1-ec11-b83b-48df37d1deb7",
+ "name": "testExisting_dataExtension",
+ "key": "testExisting_dataExtension",
+ "description": "bla bla",
+ "rowCount": 0
+ }
+ ]
+ },
+ {
+ "id": "e3774dc2-a271-4a44-8cbe-f630a6d6545e",
+ "name": "testExisting_query_WRONG_NAME",
+ "activityObjectId": "549f0568-607c-4940-afef-437965094dat",
+ "objectTypeId": 300,
+ "displayOrder": 5
+ },
+ {
+ "id": "g3774dc2-a271-4a44-8cbe-f630a6d6545e",
+ "name": "testExisting_script",
+ "activityObjectId": "39f6a488-20eb-4ba0-b0b9-023725b574e4",
+ "objectTypeId": 423,
+ "displayOrder": 6
+ }
+ ]
+ }
+ ]
+}
diff --git a/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-fixKey_pause/patch-response.json b/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-fixKey_pause/patch-response.json
new file mode 100644
index 000000000..90720a384
--- /dev/null
+++ b/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-fixKey_pause/patch-response.json
@@ -0,0 +1,85 @@
+{
+ "id": "08afb0e2-b00a-4c88-fixKey_pause",
+ "name": "testExisting_automation_fixedKey_paused",
+ "description": "testing fixKey on an a paused automation",
+ "key": "testExisting_automation_fixedKey_paused",
+ "typeId": 1,
+ "type": "scheduled",
+ "statusId": 4,
+ "status": "PausedSchedule",
+ "categoryId": 290937,
+ "schedule": {
+ "id": "b393aa6c-a4a8-4c0f-a148-9250258a7339",
+ "typeId": 3,
+ "startDate": "2022-07-30T00:00:00",
+ "endDate": "2022-07-30T00:00:00",
+ "scheduledTime": "0001-01-01T07:00:00",
+ "rangeTypeId": 0,
+ "occurrences": 1,
+ "pattern": "01",
+ "icalRecur": "FREQ=DAILY;COUNT=1;INTERVAL=1",
+ "timezoneName": "W. Europe Standard Time",
+ "scheduleStatus": "paused",
+ "timezoneId": 5
+ },
+ "steps": [
+ {
+ "id": "13fda077-0e82-4936-b936-a36b0997fc44",
+ "name": "",
+ "step": 1,
+ "activities": [
+ {
+ "id": "8081a992-a27d-4a43-984a-d60114ea1025",
+ "name": "testExisting_dataExtract",
+ "activityObjectId": "56c5370a-f988-4f36-b0ee-0f876573f6d7",
+ "objectTypeId": 73,
+ "displayOrder": 1
+ },
+ {
+ "id": "d3774dc2-a271-4a44-8cbe-f630a6d6545e",
+ "name": "testExisting_emailSend",
+ "activityObjectId": "9b1c7bf9-4964-ed11-b849-48df37d1de8b",
+ "objectTypeId": 42,
+ "displayOrder": 2
+ },
+ {
+ "id": "2c77fc42-85eb-4611-98f9-223d29d89d72",
+ "name": "testExisting_fileTransfer",
+ "activityObjectId": "72c328ac-f5b0-4e37-91d3-a775666f15a6",
+ "objectTypeId": 53,
+ "displayOrder": 3
+ },
+ {
+ "id": "298b2794-28cb-4c70-b7ad-58b2c8cf48f7",
+ "name": "testExisting_importFile",
+ "activityObjectId": "9d16f42c-2260-ed11-b849-48df37d1de8b",
+ "objectTypeId": 43,
+ "displayOrder": 4,
+ "targetDataExtensions": [
+ {
+ "id": "21711373-72c1-ec11-b83b-48df37d1deb7",
+ "name": "testExisting_dataExtension",
+ "key": "testExisting_dataExtension",
+ "description": "bla bla",
+ "rowCount": 0
+ }
+ ]
+ },
+ {
+ "id": "e3774dc2-a271-4a44-8cbe-f630a6d6545e",
+ "name": "testExisting_query_WRONG_NAME",
+ "activityObjectId": "549f0568-607c-4940-afef-437965094dat",
+ "objectTypeId": 300,
+ "displayOrder": 5
+ },
+ {
+ "id": "g3774dc2-a271-4a44-8cbe-f630a6d6545e",
+ "name": "testExisting_script",
+ "activityObjectId": "39f6a488-20eb-4ba0-b0b9-023725b574e4",
+ "objectTypeId": 423,
+ "displayOrder": 6
+ }
+ ]
+ }
+ ]
+}
diff --git a/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-fixKey_schedule/get-response.json b/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-fixKey_schedule/get-response.json
new file mode 100644
index 000000000..5f88c6f78
--- /dev/null
+++ b/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-fixKey_schedule/get-response.json
@@ -0,0 +1,85 @@
+{
+ "id": "08afb0e2-b00a-4c88-fixKey_schedule",
+ "name": "testExisting_automation_fixedKey_scheduled",
+ "description": "testing fixKey on an a scheduled automation",
+ "key": "testExisting_automation_fixKey_schedule",
+ "typeId": 1,
+ "type": "scheduled",
+ "statusId": 4,
+ "status": "Scheduled",
+ "categoryId": 290937,
+ "schedule": {
+ "id": "b393aa6c-a4a8-4c0f-a148-9250258a7339",
+ "typeId": 3,
+ "startDate": "2022-07-30T00:00:00",
+ "endDate": "2022-07-30T00:00:00",
+ "scheduledTime": "0001-01-01T07:00:00",
+ "rangeTypeId": 0,
+ "occurrences": 1,
+ "pattern": "01",
+ "icalRecur": "FREQ=DAILY;COUNT=1;INTERVAL=1",
+ "timezoneName": "W. Europe Standard Time",
+ "scheduleStatus": "paused",
+ "timezoneId": 5
+ },
+ "steps": [
+ {
+ "id": "13fda077-0e82-4936-b936-a36b0997fc44",
+ "name": "",
+ "step": 1,
+ "activities": [
+ {
+ "id": "8081a992-a27d-4a43-984a-d60114ea1025",
+ "name": "testExisting_dataExtract",
+ "activityObjectId": "56c5370a-f988-4f36-b0ee-0f876573f6d7",
+ "objectTypeId": 73,
+ "displayOrder": 1
+ },
+ {
+ "id": "d3774dc2-a271-4a44-8cbe-f630a6d6545e",
+ "name": "testExisting_emailSend",
+ "activityObjectId": "9b1c7bf9-4964-ed11-b849-48df37d1de8b",
+ "objectTypeId": 42,
+ "displayOrder": 2
+ },
+ {
+ "id": "2c77fc42-85eb-4611-98f9-223d29d89d72",
+ "name": "testExisting_fileTransfer",
+ "activityObjectId": "72c328ac-f5b0-4e37-91d3-a775666f15a6",
+ "objectTypeId": 53,
+ "displayOrder": 3
+ },
+ {
+ "id": "298b2794-28cb-4c70-b7ad-58b2c8cf48f7",
+ "name": "testExisting_importFile",
+ "activityObjectId": "9d16f42c-2260-ed11-b849-48df37d1de8b",
+ "objectTypeId": 43,
+ "displayOrder": 4,
+ "targetDataExtensions": [
+ {
+ "id": "21711373-72c1-ec11-b83b-48df37d1deb7",
+ "name": "testExisting_dataExtension",
+ "key": "testExisting_dataExtension",
+ "description": "bla bla",
+ "rowCount": 0
+ }
+ ]
+ },
+ {
+ "id": "e3774dc2-a271-4a44-8cbe-f630a6d6545e",
+ "name": "testExisting_query_WRONG_NAME",
+ "activityObjectId": "549f0568-607c-4940-afef-437965094dat",
+ "objectTypeId": 300,
+ "displayOrder": 5
+ },
+ {
+ "id": "g3774dc2-a271-4a44-8cbe-f630a6d6545e",
+ "name": "testExisting_script",
+ "activityObjectId": "39f6a488-20eb-4ba0-b0b9-023725b574e4",
+ "objectTypeId": 423,
+ "displayOrder": 6
+ }
+ ]
+ }
+ ]
+}
diff --git a/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-fixKey_schedule/patch-response.json b/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-fixKey_schedule/patch-response.json
new file mode 100644
index 000000000..aedf780bb
--- /dev/null
+++ b/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-fixKey_schedule/patch-response.json
@@ -0,0 +1,85 @@
+{
+ "id": "08afb0e2-b00a-4c88-fixKey_schedule",
+ "name": "testExisting_automation_fixedKey_scheduled",
+ "description": "testing fixKey on an a scheduled automation",
+ "key": "testExisting_automation_fixedKey_scheduled",
+ "typeId": 1,
+ "type": "scheduled",
+ "statusId": 4,
+ "status": "Scheduled",
+ "categoryId": 290937,
+ "schedule": {
+ "id": "b393aa6c-a4a8-4c0f-a148-9250258a7339",
+ "typeId": 3,
+ "startDate": "2022-07-30T00:00:00",
+ "endDate": "2022-07-30T00:00:00",
+ "scheduledTime": "0001-01-01T07:00:00",
+ "rangeTypeId": 0,
+ "occurrences": 1,
+ "pattern": "01",
+ "icalRecur": "FREQ=DAILY;COUNT=1;INTERVAL=1",
+ "timezoneName": "W. Europe Standard Time",
+ "scheduleStatus": "paused",
+ "timezoneId": 5
+ },
+ "steps": [
+ {
+ "id": "13fda077-0e82-4936-b936-a36b0997fc44",
+ "name": "",
+ "step": 1,
+ "activities": [
+ {
+ "id": "8081a992-a27d-4a43-984a-d60114ea1025",
+ "name": "testExisting_dataExtract",
+ "activityObjectId": "56c5370a-f988-4f36-b0ee-0f876573f6d7",
+ "objectTypeId": 73,
+ "displayOrder": 1
+ },
+ {
+ "id": "d3774dc2-a271-4a44-8cbe-f630a6d6545e",
+ "name": "testExisting_emailSend",
+ "activityObjectId": "9b1c7bf9-4964-ed11-b849-48df37d1de8b",
+ "objectTypeId": 42,
+ "displayOrder": 2
+ },
+ {
+ "id": "2c77fc42-85eb-4611-98f9-223d29d89d72",
+ "name": "testExisting_fileTransfer",
+ "activityObjectId": "72c328ac-f5b0-4e37-91d3-a775666f15a6",
+ "objectTypeId": 53,
+ "displayOrder": 3
+ },
+ {
+ "id": "298b2794-28cb-4c70-b7ad-58b2c8cf48f7",
+ "name": "testExisting_importFile",
+ "activityObjectId": "9d16f42c-2260-ed11-b849-48df37d1de8b",
+ "objectTypeId": 43,
+ "displayOrder": 4,
+ "targetDataExtensions": [
+ {
+ "id": "21711373-72c1-ec11-b83b-48df37d1deb7",
+ "name": "testExisting_dataExtension",
+ "key": "testExisting_dataExtension",
+ "description": "bla bla",
+ "rowCount": 0
+ }
+ ]
+ },
+ {
+ "id": "e3774dc2-a271-4a44-8cbe-f630a6d6545e",
+ "name": "testExisting_query_WRONG_NAME",
+ "activityObjectId": "549f0568-607c-4940-afef-437965094dat",
+ "objectTypeId": 300,
+ "displayOrder": 5
+ },
+ {
+ "id": "g3774dc2-a271-4a44-8cbe-f630a6d6545e",
+ "name": "testExisting_script",
+ "activityObjectId": "39f6a488-20eb-4ba0-b0b9-023725b574e4",
+ "objectTypeId": 423,
+ "displayOrder": 6
+ }
+ ]
+ }
+ ]
+}
diff --git a/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_fixKey_pause-response.xml b/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_fixKey_pause-response.xml
new file mode 100644
index 000000000..b5b72f81b
--- /dev/null
+++ b/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_fixKey_pause-response.xml
@@ -0,0 +1,32 @@
+
+
+
+ RetrieveResponse
+ urn:uuid:60a72d4a-847e-4d9b-a4eb-a42951078298
+ urn:uuid:0b59ed53-72ec-4481-ae06-4ee78912aef2
+ http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
+
+
+ 2023-06-01T12:04:20Z
+ 2023-06-01T12:09:20Z
+
+
+
+
+
+ OK
+ 3b1c8cee-b270-49cb-b77b-e7b33934d1b6
+
+
+ 08afb0e2-b00a-4c88-fixKey_pause
+ testExisting_automation_fixedKey_paused
+ testExisting_automation_fixKey_pause
+
+
+
+
diff --git a/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_fixKey_schedule-response.xml b/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_fixKey_schedule-response.xml
new file mode 100644
index 000000000..86773f622
--- /dev/null
+++ b/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_fixKey_schedule-response.xml
@@ -0,0 +1,32 @@
+
+
+
+ RetrieveResponse
+ urn:uuid:60a72d4a-847e-4d9b-a4eb-a42951078298
+ urn:uuid:0b59ed53-72ec-4481-ae06-4ee78912aef2
+ http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
+
+
+ 2023-06-01T12:04:20Z
+ 2023-06-01T12:09:20Z
+
+
+
+
+
+ OK
+ 3b1c8cee-b270-49cb-b77b-e7b33934d1b6
+
+
+ 08afb0e2-b00a-4c88-fixKey_schedule
+ testExisting_automation_fixedKey_scheduled
+ testExisting_automation_fixKey_schedule
+
+
+
+
diff --git a/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_fixedKey_paused-response.xml b/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_fixedKey_paused-response.xml
new file mode 100644
index 000000000..ce6885409
--- /dev/null
+++ b/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_fixedKey_paused-response.xml
@@ -0,0 +1,32 @@
+
+
+
+ RetrieveResponse
+ urn:uuid:60a72d4a-847e-4d9b-a4eb-a42951078298
+ urn:uuid:0b59ed53-72ec-4481-ae06-4ee78912aef2
+ http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
+
+
+ 2023-06-01T12:04:20Z
+ 2023-06-01T12:09:20Z
+
+
+
+
+
+ OK
+ 3b1c8cee-b270-49cb-b77b-e7b33934d1b6
+
+
+ 08afb0e2-b00a-4c88-fixKey_pause
+ testExisting_automation_fixedKey_paused
+ testExisting_automation_fixedKey_paused
+
+
+
+
diff --git a/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_fixedKey_scheduled-response.xml b/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_fixedKey_scheduled-response.xml
new file mode 100644
index 000000000..a1517f9db
--- /dev/null
+++ b/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_fixedKey_scheduled-response.xml
@@ -0,0 +1,32 @@
+
+
+
+ RetrieveResponse
+ urn:uuid:60a72d4a-847e-4d9b-a4eb-a42951078298
+ urn:uuid:0b59ed53-72ec-4481-ae06-4ee78912aef2
+ http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
+
+
+ 2023-06-01T12:04:20Z
+ 2023-06-01T12:09:20Z
+
+
+
+
+
+ OK
+ 3b1c8cee-b270-49cb-b77b-e7b33934d1b6
+
+
+ 08afb0e2-b00a-4c88-fixKey_schedule
+ testExisting_automation_fixedKey_scheduled
+ testExisting_automation_fixedKey_scheduled
+
+
+
+
diff --git a/test/resources/9999999/program/retrieve-response.xml b/test/resources/9999999/program/retrieve-response.xml
index bcb9045c8..6490d5491 100644
--- a/test/resources/9999999/program/retrieve-response.xml
+++ b/test/resources/9999999/program/retrieve-response.xml
@@ -33,6 +33,18 @@
testExisting_automation_pause
testExisting_automation_pause
+
+
+ 08afb0e2-b00a-4c88-fixKey_schedule
+ testExisting_automation_fixedKey_scheduled
+ testExisting_automation_fixKey_schedule
+
+
+
+ 08afb0e2-b00a-4c88-fixKey_pause
+ testExisting_automation_fixedKey_paused
+ testExisting_automation_fixKey_pause
+
diff --git a/test/resources/9999999/queryDefinition/retrieve-CustomerKey=testExisting_query_fixedKeysANDStatus=Active-response.xml b/test/resources/9999999/queryDefinition/retrieve-CustomerKey=testExisting_query_fixedKeysANDStatus=Active-response.xml
new file mode 100644
index 000000000..db31d8288
--- /dev/null
+++ b/test/resources/9999999/queryDefinition/retrieve-CustomerKey=testExisting_query_fixedKeysANDStatus=Active-response.xml
@@ -0,0 +1,30 @@
+
+
+
+ RetrieveResponse
+ urn:uuid:7ef0345e-b559-4fc4-8986-47e54e1a8a58
+ urn:uuid:b2e814a6-517c-4882-9bbb-238bfce951ce
+ http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous
+
+
+ 2023-04-11T16:33:48Z
+ 2023-04-11T16:38:48Z
+
+
+
+
+
+ OK
+ e8eb2988-2f43-4243-a6b0-6ab6b841a6ab
+
+
+ 549f0568-607c-4940-afef-437965094dat
+
+
+
+
\ No newline at end of file
diff --git a/test/type.automation.test.js b/test/type.automation.test.js
index c36ba3b64..20e872170 100644
--- a/test/type.automation.test.js
+++ b/test/type.automation.test.js
@@ -27,8 +27,8 @@ describe('type: automation', () => {
const result = cache.getCache();
assert.equal(
result.automation ? Object.keys(result.automation).length : 0,
- 2,
- 'only two automations expected'
+ 4,
+ 'only four automations expected'
);
assert.deepEqual(
await testUtils.getActualJson('testExisting_automation', 'automation'),
@@ -50,7 +50,7 @@ describe('type: automation', () => {
assert.equal(
testUtils.getAPIHistoryLength(),
- 15,
+ 17,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
@@ -62,15 +62,24 @@ describe('type: automation', () => {
});
it('Should create & update a automation', async () => {
// WHEN
- await handler.deploy('testInstance/testBU', ['automation']);
+ const deployResult = await handler.deploy('testInstance/testBU', ['automation']);
// THEN
assert.equal(process.exitCode, false, 'deploy should not have thrown an error');
+ // check how many items were deployed
+ assert.equal(
+ deployResult['testInstance/testBU']?.automation
+ ? Object.keys(deployResult['testInstance/testBU']?.automation).length
+ : 0,
+ 2,
+ 'two automations to be deployed'
+ );
+
// get results from cache
- const result = cache.getCache();
+ const cacheResult = cache.getCache();
assert.equal(
- result.automation ? Object.keys(result.automation).length : 0,
- 3,
+ cacheResult.automation ? Object.keys(cacheResult.automation).length : 0,
+ 5,
'three automations expected'
);
// insert
@@ -116,13 +125,13 @@ describe('type: automation', () => {
);
return;
});
- it('Should update & schedule an automation with --execute option', async () => {
+ it('Should update & schedule an automation with --schedule option', async () => {
// WHEN
handler.setOptions({ schedule: true });
const deployed = await handler.deploy(
'testInstance/testBU',
['automation'],
- ['testExisting_automation']
+ ['testExisting_automation', 'testNew_automation']
);
// THEN
assert.equal(
@@ -135,20 +144,27 @@ describe('type: automation', () => {
const cached = cache.getCache();
assert.equal(
cached.automation ? Object.keys(cached.automation).length : 0,
- 2,
- 'two cached automation expected'
+ 5,
+ 'five cached automation expected'
);
assert.equal(
deployed['testInstance/testBU'].automation
? Object.keys(deployed['testInstance/testBU'].automation).length
: 0,
- 1,
- 'one deployed automation expected'
+ 2,
+ 'two deployed automation expected'
);
assert.equal(
deployed['testInstance/testBU'].automation
? Object.keys(deployed['testInstance/testBU'].automation)[0]
: null,
+ 'testNew_automation',
+ 'expected specific automation to have been deployed'
+ );
+ assert.equal(
+ deployed['testInstance/testBU'].automation
+ ? Object.keys(deployed['testInstance/testBU'].automation)[1]
+ : null,
'testExisting_automation',
'expected specific automation to have been deployed'
);
@@ -173,7 +189,7 @@ describe('type: automation', () => {
assert.equal(
testUtils.getAPIHistoryLength(),
- 19,
+ 24,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
@@ -184,7 +200,7 @@ describe('type: automation', () => {
const deployed = await handler.deploy(
'testInstance/testBU',
['automation'],
- ['testExisting_automation']
+ ['testExisting_automation', 'testNew_automation']
);
// THEN
assert.equal(
@@ -197,24 +213,30 @@ describe('type: automation', () => {
const cached = cache.getCache();
assert.equal(
cached.automation ? Object.keys(cached.automation).length : 0,
- 2,
- 'two cached automation expected'
+ 5,
+ 'five cached automation expected'
);
assert.equal(
deployed['testInstance/testBU'].automation
? Object.keys(deployed['testInstance/testBU'].automation).length
: 0,
- 1,
- 'one deployed automation expected'
+ 2,
+ 'two deployed automation expected'
);
assert.equal(
deployed['testInstance/testBU'].automation
? Object.keys(deployed['testInstance/testBU'].automation)[0]
: null,
+ 'testNew_automation',
+ 'expected specific automation to have been deployed'
+ );
+ assert.equal(
+ deployed['testInstance/testBU'].automation
+ ? Object.keys(deployed['testInstance/testBU'].automation)[1]
+ : null,
'testExisting_automation',
'expected specific automation to have been deployed'
);
-
// update
assert.deepEqual(
await testUtils.getActualJson('testExisting_automation', 'automation'),
@@ -235,7 +257,296 @@ describe('type: automation', () => {
assert.equal(
testUtils.getAPIHistoryLength(),
- 16,
+ 20,
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
+ );
+ return;
+ });
+ });
+ describe('FixKeys ================', () => {
+ beforeEach(() => {
+ testUtils.mockSetup(true);
+ });
+ it('Should run fixKeys but not find fixable keys and hence stop', async () => {
+ // WHEN
+ handler.setOptions({ skipInteraction: { fixKeysReretrieve: false } });
+ const resultFixKeys = await handler.fixKeys('testInstance/testBU', 'automation', [
+ 'testExisting_automation',
+ ]);
+ // THEN
+ assert.equal(process.exitCode, false, 'fixKeys should not have thrown an error');
+ // check which keys were fixed
+ assert.equal(
+ resultFixKeys['testInstance/testBU'].length,
+ 0,
+ 'expected to find no keys to be fixed'
+ );
+
+ // get results from cache
+ const result = cache.getCache();
+ assert.equal(
+ result.automation ? Object.keys(result.automation).length : 0,
+ 1,
+ 'one automation expected'
+ );
+ // check number of API calls
+ assert.equal(
+ testUtils.getAPIHistoryLength(),
+ 14,
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
+ );
+ return;
+ });
+ it('Should fixKeys by key w/o re-retrieving, auto-schedule', async () => {
+ // WHEN
+ handler.setOptions({ skipInteraction: { fixKeysReretrieve: false } });
+ const resultFixKeys = await handler.fixKeys('testInstance/testBU', 'automation', [
+ 'testExisting_automation_fixKey_schedule',
+ 'testExisting_automation',
+ ]);
+ 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_automation_fixedKey_scheduled',
+ '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_automation_fixedKey_scheduled',
+ 'automation'
+ ),
+ await testUtils.getExpectedJson('9999999', 'automation', 'patch_fixKeys-schedule'),
+ 'returned metadata was not equal expected for update automation'
+ );
+ expect(
+ file(
+ testUtils.getActualDoc(
+ 'testExisting_automation_fixedKey_scheduled',
+ 'automation'
+ )
+ )
+ ).to.exist;
+ // check number of API calls
+ assert.equal(
+ testUtils.getAPIHistoryLength(),
+ 29,
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
+ );
+ return;
+ });
+ it('Should fixKeys by key w/o re-retrieving, auto-schedule and then --execute', async () => {
+ // WHEN
+ handler.setOptions({ skipInteraction: { fixKeysReretrieve: false }, execute: true });
+ const resultFixKeys = await handler.fixKeys('testInstance/testBU', 'automation', [
+ 'testExisting_automation_fixKey_schedule',
+ 'testExisting_automation',
+ ]);
+ 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_automation_fixedKey_scheduled',
+ '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_automation_fixedKey_scheduled',
+ 'automation'
+ ),
+ await testUtils.getExpectedJson('9999999', 'automation', 'patch_fixKeys-schedule'),
+ 'returned metadata was not equal expected for update automation'
+ );
+ expect(
+ file(
+ testUtils.getActualDoc(
+ 'testExisting_automation_fixedKey_scheduled',
+ 'automation'
+ )
+ )
+ ).to.exist;
+ // 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 by key w/o re-retrieving, auto-schedule and then --schedule', async () => {
+ // WHEN
+ handler.setOptions({ skipInteraction: { fixKeysReretrieve: false }, schedule: true });
+ const resultFixKeys = await handler.fixKeys('testInstance/testBU', 'automation', [
+ 'testExisting_automation_fixKey_schedule',
+ 'testExisting_automation',
+ ]);
+ 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_automation_fixedKey_scheduled',
+ '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_automation_fixedKey_scheduled',
+ 'automation'
+ ),
+ await testUtils.getExpectedJson('9999999', 'automation', 'patch_fixKeys-schedule'),
+ 'returned metadata was not equal expected for update automation'
+ );
+ expect(
+ file(
+ testUtils.getActualDoc(
+ 'testExisting_automation_fixedKey_scheduled',
+ 'automation'
+ )
+ )
+ ).to.exist;
+ // check number of API calls
+ assert.equal(
+ testUtils.getAPIHistoryLength(),
+ 32,
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
+ );
+ return;
+ });
+ it('Should fixKeys by key w/o re-retrieving, deploy paused', async () => {
+ // WHEN
+ handler.setOptions({ skipInteraction: { fixKeysReretrieve: false } });
+ const resultFixKeys = await handler.fixKeys('testInstance/testBU', 'automation', [
+ 'testExisting_automation_fixKey_pause',
+ ]);
+ 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_automation_fixedKey_paused',
+ '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_automation_fixedKey_paused',
+ 'automation'
+ ),
+ await testUtils.getExpectedJson('9999999', 'automation', 'patch_fixKeys-pause'),
+ 'returned metadata was not equal expected for update automation'
+ );
+ expect(
+ file(
+ testUtils.getActualDoc('testExisting_automation_fixedKey_paused', 'automation')
+ )
+ ).to.exist;
+ // check number of API calls
+ assert.equal(
+ testUtils.getAPIHistoryLength(),
+ 26,
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
+ );
+ return;
+ });
+ it('Should fixKeys by key w/o re-retrieving, deploy paused and then --execute', async () => {
+ // WHEN
+ handler.setOptions({ skipInteraction: { fixKeysReretrieve: false }, execute: true });
+ const resultFixKeys = await handler.fixKeys('testInstance/testBU', 'automation', [
+ 'testExisting_automation_fixKey_pause',
+ 'testExisting_automation',
+ ]);
+ 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_automation_fixedKey_paused',
+ '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_automation_fixedKey_paused',
+ 'automation'
+ ),
+ await testUtils.getExpectedJson('9999999', 'automation', 'patch_fixKeys-pause'),
+ 'returned metadata was not equal expected for update automation'
+ );
+ expect(
+ file(
+ testUtils.getActualDoc('testExisting_automation_fixedKey_paused', 'automation')
+ )
+ ).to.exist;
+ // check number of API calls
+ assert.equal(
+ testUtils.getAPIHistoryLength(),
+ 30,
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
+ );
+ return;
+ });
+ it('Should fixKeys by key w/o re-retrieving, deploy paused and then --schedule', async () => {
+ // WHEN
+ handler.setOptions({ skipInteraction: { fixKeysReretrieve: false }, schedule: true });
+ const resultFixKeys = await handler.fixKeys('testInstance/testBU', 'automation', [
+ 'testExisting_automation_fixKey_pause',
+ 'testExisting_automation',
+ ]);
+ 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_automation_fixedKey_paused',
+ '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_automation_fixedKey_paused',
+ 'automation'
+ ),
+ await testUtils.getExpectedJson('9999999', 'automation', 'patch_fixKeys-pause'),
+ 'returned metadata was not equal expected for update automation'
+ );
+ expect(
+ file(
+ testUtils.getActualDoc('testExisting_automation_fixedKey_paused', 'automation')
+ )
+ ).to.exist;
+ // check number of API calls
+ assert.equal(
+ testUtils.getAPIHistoryLength(),
+ 32,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
@@ -333,7 +644,7 @@ describe('type: automation', () => {
);
assert.equal(
testUtils.getAPIHistoryLength(),
- 15,
+ 17,
'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
);
return;
diff --git a/test/type.query.test.js b/test/type.query.test.js
index 467344a1e..c63420be7 100644
--- a/test/type.query.test.js
+++ b/test/type.query.test.js
@@ -351,7 +351,7 @@ describe('type: query', () => {
);
return;
});
- it('Should fixKeys and deploy by key WITHOUT re-retrieving dependent types', async () => {
+ it('Should fixKeys by key WITHOUT re-retrieving dependent types', async () => {
// WHEN
handler.setOptions({ skipInteraction: { fixKeysReretrieve: false } });
const resultFixKeys = await handler.fixKeys('testInstance/testBU', 'query', [
@@ -387,7 +387,47 @@ describe('type: query', () => {
);
return;
});
- it('Should fixKeys and deploy by key AND re-retrieve dependent types', async () => {
+ it('Should fixKeys by key WITHOUT re-retrieving dependent types and then --execute', async () => {
+ // WHEN
+ handler.setOptions({ skipInteraction: { fixKeysReretrieve: false }, execute: 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 with --execute 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(),
+ 18,
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
+ );
+ return;
+ });
+ it('Should fixKeys by key AND re-retrieve dependent types', async () => {
// WHEN
handler.setOptions({ skipInteraction: { fixKeysReretrieve: true } });
const resultFixKeys = await handler.fixKeys('testInstance/testBU', 'query', [
@@ -418,12 +458,52 @@ describe('type: query', () => {
// check number of API calls
assert.equal(
testUtils.getAPIHistoryLength(),
- 31,
+ 33,
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
+ );
+ return;
+ });
+ it('Should fixKeys by key AND re-retrieve dependent types and then --execute', async () => {
+ // WHEN
+ handler.setOptions({ skipInteraction: { fixKeysReretrieve: true }, execute: 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 with --execute 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(),
+ 35,
'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 () => {
+ it('Should fixKeys via --like WITHOUT re-retrieving dependent types', async () => {
// WHEN
handler.setOptions({
like: { key: 'testExisting_query_f%' },