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.
Files changed (237) hide show
  1. package/.coverage-comment-template.svelte +177 -161
  2. package/.eslintrc.json +4 -4
  3. package/.github/ISSUE_TEMPLATE/bug.yml +2 -0
  4. package/.github/PULL_REQUEST_TEMPLATE.md +2 -2
  5. package/.github/dependabot.yml +8 -0
  6. package/.github/workflows/coverage-base-update.yml +6 -2
  7. package/.github/workflows/coverage-develop-branch.yml +7 -8
  8. package/.github/workflows/coverage-main-branch.yml +7 -8
  9. package/.github/workflows/coverage.yml +7 -4
  10. package/.husky/post-checkout +4 -2
  11. package/.husky/post-merge +1 -0
  12. package/.vscode/extensions.json +4 -0
  13. package/docs/dist/documentation.md +756 -294
  14. package/lib/Deployer.js +28 -28
  15. package/lib/MetadataTypeDefinitions.js +1 -1
  16. package/lib/MetadataTypeInfo.js +1 -1
  17. package/lib/Retriever.js +1 -1
  18. package/lib/cli.js +184 -6
  19. package/lib/index.js +493 -22
  20. package/lib/metadataTypes/Asset.js +10 -11
  21. package/lib/metadataTypes/AttributeGroup.js +76 -2
  22. package/lib/metadataTypes/AttributeSet.js +260 -0
  23. package/lib/metadataTypes/Automation.js +771 -247
  24. package/lib/metadataTypes/DataExtension.js +7 -7
  25. package/lib/metadataTypes/DataExtensionField.js +1 -1
  26. package/lib/metadataTypes/Event.js +2 -3
  27. package/lib/metadataTypes/Folder.js +1 -1
  28. package/lib/metadataTypes/Journey.js +5 -6
  29. package/lib/metadataTypes/MetadataType.js +187 -60
  30. package/lib/metadataTypes/MobileKeyword.js +8 -8
  31. package/lib/metadataTypes/MobileMessage.js +5 -5
  32. package/lib/metadataTypes/Query.js +47 -5
  33. package/lib/metadataTypes/Script.js +3 -3
  34. package/lib/metadataTypes/TransactionalSMS.js +5 -5
  35. package/lib/metadataTypes/TriggeredSend.js +25 -50
  36. package/lib/metadataTypes/User.js +7 -4
  37. package/lib/metadataTypes/definitions/Asset.definition.js +1 -0
  38. package/lib/metadataTypes/definitions/AttributeGroup.definition.js +117 -106
  39. package/lib/metadataTypes/definitions/{SetDefinition.definition.js → AttributeSet.definition.js} +54 -27
  40. package/lib/metadataTypes/definitions/Automation.definition.js +74 -21
  41. package/lib/metadataTypes/definitions/DataExtension.definition.js +1 -0
  42. package/lib/metadataTypes/definitions/DataExtract.definition.js +1 -0
  43. package/lib/metadataTypes/definitions/EmailSend.definition.js +1 -0
  44. package/lib/metadataTypes/definitions/Event.definition.js +1 -0
  45. package/lib/metadataTypes/definitions/Filter.definition.js +1 -0
  46. package/lib/metadataTypes/definitions/ImportFile.definition.js +37 -6
  47. package/lib/metadataTypes/definitions/MobileKeyword.definition.js +1 -0
  48. package/lib/metadataTypes/definitions/Query.definition.js +1 -0
  49. package/lib/metadataTypes/definitions/Role.definition.js +1 -0
  50. package/lib/metadataTypes/definitions/TriggeredSend.definition.js +2 -0
  51. package/lib/metadataTypes/definitions/User.definition.js +1 -0
  52. package/lib/util/cache.js +9 -4
  53. package/lib/util/cli.js +40 -0
  54. package/lib/util/devops.js +13 -11
  55. package/lib/util/file.js +2 -2
  56. package/lib/util/init.js +84 -0
  57. package/lib/util/util.js +268 -137
  58. package/package.json +11 -11
  59. package/test/general.test.js +26 -0
  60. package/test/mockRoot/.mcdevrc.json +1 -1
  61. package/test/mockRoot/deploy/testInstance/testBU/automation/testExisting_automation.automation-meta.json +52 -0
  62. package/test/mockRoot/deploy/testInstance/testBU/automation/testNew_automation.automation-meta.json +45 -0
  63. package/test/mockRoot/deploy/testInstance/testBU/dataExtract/testExisting_dataExtract.dataExtract-meta.json +35 -0
  64. package/test/mockRoot/deploy/testInstance/testBU/dataExtract/testNew_dataExtract.dataExtract-meta.json +35 -0
  65. package/test/mockRoot/deploy/testInstance/testBU/fileTransfer/testExisting_fileTransfer.fileTransfer-meta.json +17 -0
  66. package/test/mockRoot/deploy/testInstance/testBU/fileTransfer/testNew_fileTransfer.fileTransfer-meta.json +17 -0
  67. package/test/mockRoot/deploy/testInstance/testBU/importFile/testExisting_importFile.importFile-meta.json +29 -0
  68. package/test/mockRoot/deploy/testInstance/testBU/importFile/testNew_importFile.importFile-meta.json +29 -0
  69. package/test/mockRoot/deploy/testInstance/testBU/query/{testExistingQuery.query-meta.json → testExisting_query.query-meta.json} +2 -2
  70. package/test/mockRoot/deploy/testInstance/testBU/query/testExisting_query_fixKeys.query-meta.json +11 -0
  71. package/test/mockRoot/deploy/testInstance/testBU/query/testExisting_query_fixKeys.query-meta.sql +6 -0
  72. package/test/mockRoot/deploy/testInstance/testBU/query/{testNewQuery.query-meta.json → testNew_query.query-meta.json} +2 -2
  73. package/test/mockRoot/deploy/testInstance/testBU/script/testExisting_script.script-meta.json +6 -0
  74. package/test/mockRoot/deploy/testInstance/testBU/script/testExisting_script.script-meta.ssjs +1 -0
  75. package/test/mockRoot/deploy/testInstance/testBU/script/testNew_script.script-meta.json +6 -0
  76. package/test/mockRoot/deploy/testInstance/testBU/script/testNew_script.script-meta.ssjs +1 -0
  77. package/test/mockRoot/deploy/testInstance/testBU/triggeredSend/testExisting_triggeredSend.triggeredSend-meta.json +29 -0
  78. package/test/mockRoot/deploy/testInstance/testBU/triggeredSend/testNew_triggeredSend.triggeredSend-meta.json +29 -0
  79. package/test/resourceFactory.js +132 -24
  80. package/test/resources/1111111/accountUser/retrieve-ActiveFlag=falseANDCustomerKey=testExisting_userANDEmaillike@-response.xml +27 -0
  81. package/test/resources/1111111/accountUser/retrieve-ActiveFlag=falseANDEmaillike@-response.xml +156 -0
  82. package/test/resources/1111111/accountUser/retrieve-ActiveFlag=trueANDEmailisNullORNamelikeapp userANDMustChangePassword=false-response.xml +87 -0
  83. package/test/resources/1111111/accountUser/retrieve-ActiveFlag=trueANDEmaillike@-response.xml +156 -0
  84. package/test/resources/1111111/accountUser/retrieve-CustomerKey=testExisting_userANDActiveFlag=trueANDEmailisNullORNamelikeapp userANDMustChangePassword=false-response.xml +27 -0
  85. package/test/resources/1111111/accountUserAccount/retrieve-AccountUser.AccountUserID=700301950-response.xml +60 -0
  86. package/test/resources/1111111/user/retrieve-expected.md +4 -2
  87. package/test/resources/9999999/attributeGroup/retrieve-expected.json +25 -0
  88. package/test/resources/9999999/attributeSet/retrieve-expected.json +748 -0
  89. package/test/resources/9999999/automation/build-expected.json +57 -0
  90. package/test/resources/9999999/automation/create-expected.json +45 -0
  91. package/test/resources/9999999/automation/create-testNew_automation-expected.md +28 -0
  92. package/test/resources/9999999/automation/delete-response.xml +40 -0
  93. package/test/resources/9999999/automation/patch_fixKeys-pause-expected.json +44 -0
  94. package/test/resources/9999999/automation/patch_fixKeys-schedule-expected.json +44 -0
  95. package/test/resources/9999999/automation/perform-08afb0e2-b00a-4c88-ad2e-1f7f8788c560-response.xml +42 -0
  96. package/test/resources/9999999/automation/perform-08afb0e2-b00a-4c88-fixKey_pause-response.xml +42 -0
  97. package/test/resources/9999999/automation/perform-08afb0e2-b00a-4c88-fixKey_schedule-response.xml +42 -0
  98. package/test/resources/9999999/automation/perform-a8afb0e2-b00a-4c88-ad2e-1f7f8788c560-response.xml +42 -0
  99. package/test/resources/9999999/automation/retrieve-expected.json +57 -0
  100. package/test/resources/9999999/automation/retrieve-testExisting_automation-expected.md +30 -0
  101. package/test/resources/9999999/automation/schedule-08afb0e2-b00a-4c88-ad2e-1f7f8788c560-response.xml +52 -0
  102. package/test/resources/9999999/automation/schedule-08afb0e2-b00a-4c88-ad2e-pause-response.xml +38 -0
  103. package/test/resources/9999999/automation/schedule-08afb0e2-b00a-4c88-fixKey_pause-response.xml +52 -0
  104. package/test/resources/9999999/automation/schedule-08afb0e2-b00a-4c88-fixKey_schedule-response.xml +52 -0
  105. package/test/resources/9999999/automation/schedule-a8afb0e2-b00a-4c88-ad2e-1f7f8788c560-response.xml +52 -0
  106. package/test/resources/9999999/automation/template-expected.json +57 -0
  107. package/test/resources/9999999/automation/update-expected.json +45 -0
  108. package/test/resources/9999999/automation/update-testExisting_automation-expected.md +28 -0
  109. package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-1f7f8788c560/get-response.json +85 -0
  110. package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-1f7f8788c560/patch-response.json +85 -0
  111. package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-pause/get-response.json +85 -0
  112. package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-ad2e-pause/patch-response.json +85 -0
  113. package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-fixKey_pause/get-response.json +85 -0
  114. package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-fixKey_pause/patch-response.json +85 -0
  115. package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-fixKey_schedule/get-response.json +85 -0
  116. package/test/resources/9999999/automation/v1/automations/08afb0e2-b00a-4c88-fixKey_schedule/patch-response.json +85 -0
  117. package/test/resources/9999999/automation/v1/automations/a8afb0e2-b00a-4c88-ad2e-1f7f8788c560/get-response.json +85 -0
  118. package/test/resources/9999999/automation/v1/automations/post-response.json +86 -0
  119. package/test/resources/9999999/automation/v1/dataextracts/56c5370a-f988-4f36-b0ee-0f876573f6d7/get-response.json +38 -0
  120. package/test/resources/9999999/automation/v1/dataextracts/56c5370a-f988-4f36-b0ee-0f876573f6d7/patch-response.json +38 -0
  121. package/test/resources/9999999/automation/v1/dataextracts/get-response.json +20 -0
  122. package/test/resources/9999999/automation/v1/dataextracts/post-response.json +38 -0
  123. package/test/resources/9999999/automation/v1/dataextracttypes/get-response.json +50 -0
  124. package/test/resources/9999999/automation/v1/filetransfers/72c328ac-f5b0-4e37-91d3-a775666f15a6/get-response.json +18 -0
  125. package/test/resources/9999999/automation/v1/filetransfers/72c328ac-f5b0-4e37-91d3-a775666f15a6/patch-response.json +18 -0
  126. package/test/resources/9999999/automation/v1/filetransfers/get-response.json +15 -0
  127. package/test/resources/9999999/automation/v1/filetransfers/post-response.json +18 -0
  128. package/test/resources/9999999/automation/v1/ftplocations/get-response.json +18 -0
  129. package/test/resources/9999999/automation/v1/imports/9d16f42c-2260-ed11-b849-48df37d1de8b/patch-response.json +31 -0
  130. package/test/resources/9999999/automation/v1/imports/get-response.json +38 -0
  131. package/test/resources/9999999/automation/v1/imports/post-response.json +30 -0
  132. package/test/resources/9999999/automation/v1/queries/549f0568-607c-4940-afef-437965094dae/actions/start/post-response.txt +1 -0
  133. package/test/resources/9999999/automation/v1/queries/549f0568-607c-4940-afef-437965094dat/actions/start/post-response.txt +1 -0
  134. package/test/resources/9999999/automation/v1/queries/549f0568-607c-4940-afef-437965094dat/get-response.json +2 -2
  135. package/test/resources/9999999/automation/v1/queries/549f0568-607c-4940-afef-437965094dat/patch-response.json +2 -2
  136. package/test/resources/9999999/automation/v1/queries/549f0568-607c-4940-afef-437965094dat_fixKeys/get-response.json +17 -0
  137. package/test/resources/9999999/automation/v1/queries/549f0568-607c-4940-afef-437965094dat_fixKeys/patch-response.json +18 -0
  138. package/test/resources/9999999/automation/v1/queries/get-response.json +22 -5
  139. package/test/resources/9999999/automation/v1/queries/post-response.json +2 -2
  140. package/test/resources/9999999/automation/v1/scripts/39f6a488-20eb-4ba0-b0b9-023725b574e4/patch-response.json +10 -0
  141. package/test/resources/9999999/automation/v1/scripts/get-response.json +27 -0
  142. package/test/resources/9999999/automation/v1/scripts/post-response.json +10 -0
  143. package/test/resources/9999999/dataExtension/retrieve-Name=testExisting_dataExtension-response.xml +52 -0
  144. package/test/resources/9999999/dataExtensionField/retrieve-DataExtension.CustomerKey=testExisting_dataExtension-response.xml +98 -0
  145. package/test/resources/9999999/dataExtensionField/retrieve-DataExtension.CustomerKey=testNew_dataExtensionORDataExtension.CustomerKey=testExisting_dataExtension-response.xml +99 -0
  146. package/test/resources/9999999/dataExtract/build-expected.json +35 -0
  147. package/test/resources/9999999/dataExtract/get-expected.json +39 -0
  148. package/test/resources/9999999/dataExtract/patch-expected.json +37 -0
  149. package/test/resources/9999999/dataExtract/post-expected.json +37 -0
  150. package/test/resources/9999999/dataExtract/template-expected.json +35 -0
  151. package/test/resources/9999999/dataFolder/retrieve-ContentType=automations-response.xml +48 -0
  152. package/test/resources/9999999/dataFolder/retrieve-ContentType=contextual_suppression_listORContentType=publicationORContentType=suppression_listORContentType=mysubsORContentType=list-response.xml +136 -0
  153. package/test/resources/9999999/dataFolder/retrieve-ContentType=queryactivity-response.xml +48 -0
  154. package/test/resources/9999999/dataFolder/retrieve-ContentType=ssjsactivity-response.xml +48 -0
  155. package/test/resources/9999999/dataFolder/retrieve-ContentType=triggered_send_journeybuilderORContentType=triggered_sendORContentType=hidden-response.xml +276 -0
  156. package/test/resources/9999999/dataFolder/retrieve-response.xml +45 -0
  157. package/test/resources/9999999/email/retrieve-response.xml +203 -0
  158. package/test/resources/9999999/emailSendDefinition/retrieve-IsPlatformObject=falseANDDescriptionnotEqualsSFSendDefinition-response.xml +85 -0
  159. package/test/resources/9999999/fileTransfer/build-expected.json +15 -0
  160. package/test/resources/9999999/fileTransfer/get-expected.json +17 -0
  161. package/test/resources/9999999/fileTransfer/patch-expected.json +17 -0
  162. package/test/resources/9999999/fileTransfer/post-expected.json +17 -0
  163. package/test/resources/9999999/fileTransfer/template-expected.json +15 -0
  164. package/test/resources/9999999/hub/v1/contacts/schema/attributeGroups/get-response.json +585 -0
  165. package/test/resources/9999999/hub/v1/contacts/schema/setDefinitions/get-response.json +19807 -0
  166. package/test/resources/9999999/importFile/build-expected.json +27 -0
  167. package/test/resources/9999999/importFile/get-expected.json +29 -0
  168. package/test/resources/9999999/importFile/patch-expected.json +29 -0
  169. package/test/resources/9999999/importFile/post-expected.json +29 -0
  170. package/test/resources/9999999/importFile/template-expected.json +27 -0
  171. package/test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow/get-response.json +21 -0
  172. package/test/resources/9999999/legacy/v1/beta/automations/notifications/RkpOcE9qSVh2VUdnYTVJbWFfWW14dzoyNTow/post-response.json +0 -0
  173. package/test/resources/9999999/legacy/v1/beta/bulk/automations/automation/definition/get-response.json +30 -0
  174. package/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation-response.xml +30 -0
  175. package/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_fixKey_pause-response.xml +32 -0
  176. package/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_fixKey_schedule-response.xml +32 -0
  177. package/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_fixedKey_paused-response.xml +32 -0
  178. package/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_fixedKey_scheduled-response.xml +32 -0
  179. package/test/resources/9999999/program/retrieve-CustomerKey=testExisting_automation_pause-response.xml +30 -0
  180. package/test/resources/9999999/program/retrieve-CustomerKey=testNew_automation-response.xml +30 -0
  181. package/test/resources/9999999/program/retrieve-Name=testExisting_automation-response.xml +31 -0
  182. package/test/resources/9999999/program/retrieve-response.xml +50 -0
  183. package/test/resources/9999999/query/build-expected.json +2 -2
  184. package/test/resources/9999999/query/get-expected.json +2 -2
  185. package/test/resources/9999999/query/get2-expected.json +2 -2
  186. package/test/resources/9999999/query/patch-expected.json +2 -2
  187. package/test/resources/9999999/query/patch_fixKeys-expected.json +11 -0
  188. package/test/resources/9999999/query/patch_fixKeys-expected.sql +6 -0
  189. package/test/resources/9999999/query/post-expected.json +2 -2
  190. package/test/resources/9999999/query/template-expected.json +2 -2
  191. package/test/resources/9999999/queryDefinition/retrieve-CustomerKey=testExisting_query_fixKeysANDStatus=Active-response.xml +30 -0
  192. package/test/resources/9999999/queryDefinition/retrieve-CustomerKey=testExisting_query_fixedKeysANDStatus=Active-response.xml +30 -0
  193. package/test/resources/9999999/queryDefinition/retrieve-CustomerKey=testNew_queryANDStatus=Active-response.xml +30 -0
  194. package/test/resources/9999999/script/build-expected.json +6 -0
  195. package/test/resources/9999999/script/build-expected.ssjs +1 -0
  196. package/test/resources/9999999/script/get-expected.json +8 -0
  197. package/test/resources/9999999/script/get-expected.ssjs +1 -0
  198. package/test/resources/9999999/script/get_noScriptTag-expected.html +1 -0
  199. package/test/resources/9999999/script/get_noScriptTag-expected.json +8 -0
  200. package/test/resources/9999999/script/patch-expected.json +8 -0
  201. package/test/resources/9999999/script/patch-expected.ssjs +1 -0
  202. package/test/resources/9999999/script/post-expected.json +8 -0
  203. package/test/resources/9999999/script/post-expected.ssjs +1 -0
  204. package/test/resources/9999999/script/template-expected.json +6 -0
  205. package/test/resources/9999999/script/template-expected.ssjs +1 -0
  206. package/test/resources/9999999/triggeredSend/build-expected.json +29 -0
  207. package/test/resources/9999999/triggeredSend/get-expected.json +29 -0
  208. package/test/resources/9999999/triggeredSend/patch-expected.json +29 -0
  209. package/test/resources/9999999/triggeredSend/post-expected.json +29 -0
  210. package/test/resources/9999999/triggeredSend/template-expected.json +29 -0
  211. package/test/resources/9999999/triggeredSendDefinition/create-response.xml +75 -0
  212. package/test/resources/9999999/triggeredSendDefinition/delete-response.xml +36 -0
  213. package/test/resources/9999999/triggeredSendDefinition/{retrieve-response.xml → retrieve-TriggeredSendStatusINNew,Active,Inactive,Moved,Canceled-response.xml} +4 -4
  214. package/test/resources/9999999/triggeredSendDefinition/update-response.xml +74 -0
  215. package/test/type.attributeGroup.test.js +55 -0
  216. package/test/type.attributeSet.test.js +55 -0
  217. package/test/type.automation.test.js +886 -0
  218. package/test/type.dataExtension.test.js +3 -1
  219. package/test/type.dataExtract.test.js +187 -0
  220. package/test/type.fileTransfer.test.js +185 -0
  221. package/test/type.importFile.test.js +186 -0
  222. package/test/type.mobileKeyword.test.js +0 -1
  223. package/test/type.query.test.js +497 -33
  224. package/test/type.script.test.js +367 -0
  225. package/test/type.triggeredSend.test.js +152 -0
  226. package/test/type.user.test.js +37 -11
  227. package/test/utils.js +10 -6
  228. package/.coverage-comment-template.md +0 -20
  229. package/lib/metadataTypes/SetDefinition.js +0 -37
  230. /package/test/mockRoot/deploy/testInstance/testBU/query/{testExistingQuery.query-meta.sql → testExisting_query.query-meta.sql} +0 -0
  231. /package/test/mockRoot/deploy/testInstance/testBU/query/{testNewQuery.query-meta.sql → testNew_query.query-meta.sql} +0 -0
  232. /package/test/resources/1111111/accountUser/{retrieve-response.xml → retrieve-ActiveFlag=trueANDCustomerKey=testExisting_userANDEmaillike@-response.xml} +0 -0
  233. /package/test/resources/1111111/accountUserAccount/{retrieve-response.xml → retrieve-AccountUser.AccountUserIDIN700301950,700301951,7471228-response.xml} +0 -0
  234. /package/test/resources/1111111/businessUnit/{retrieve-response.xml → retrieve-ID=1111111-response.xml} +0 -0
  235. /package/test/resources/1111111/list/{retrieve-response.xml → retrieve-CustomerKey=All SubscribersORListName=All Subscribers-response.xml} +0 -0
  236. /package/test/resources/1111111/role/{retrieve-response.xml → retrieve-IsPrivate=false-response.xml} +0 -0
  237. /package/test/resources/9999999/queryDefinition/{retrieve-response.xml → retrieve-CustomerKey=testExisting_queryANDStatus=Active-response.xml} +0 -0
@@ -27,21 +27,21 @@ describe('type: query', () => {
27
27
  const result = cache.getCache();
28
28
  assert.equal(
29
29
  result.query ? Object.keys(result.query).length : 0,
30
- 2,
31
- 'only two queries expected'
30
+ 3,
31
+ 'only three queries expected'
32
32
  );
33
33
  // normal test
34
34
  assert.deepEqual(
35
- await testUtils.getActualJson('testExistingQuery', 'query'),
35
+ await testUtils.getActualJson('testExisting_query', 'query'),
36
36
  await testUtils.getExpectedJson('9999999', 'query', 'get'),
37
37
  'returned metadata with correct key was not equal expected'
38
38
  );
39
- expect(file(testUtils.getActualFile('testExistingQuery', 'query', 'sql'))).to.equal(
39
+ expect(file(testUtils.getActualFile('testExisting_query', 'query', 'sql'))).to.equal(
40
40
  file(testUtils.getExpectedFile('9999999', 'query', 'get', 'sql'))
41
41
  );
42
42
  // check if targetKey was overwritten
43
43
  assert.deepEqual(
44
- await testUtils.getActualJson('testExistingQuery2', 'query'),
44
+ await testUtils.getActualJson('testExisting_query2', 'query'),
45
45
  await testUtils.getExpectedJson('9999999', 'query', 'get2'),
46
46
  'returned metadata with wrong key was not equal expected'
47
47
  );
@@ -53,9 +53,9 @@ describe('type: query', () => {
53
53
  );
54
54
  return;
55
55
  });
56
- it('Should retrieve one specific query', async () => {
56
+ it('Should retrieve one specific query by key', async () => {
57
57
  // WHEN
58
- await handler.retrieve('testInstance/testBU', ['query'], ['testExistingQuery']);
58
+ await handler.retrieve('testInstance/testBU', ['query'], ['testExisting_query']);
59
59
  // THEN
60
60
  assert.equal(process.exitCode, false, 'retrieve should not have thrown an error');
61
61
  // get results from cache
@@ -66,11 +66,11 @@ describe('type: query', () => {
66
66
  'only one query expected'
67
67
  );
68
68
  assert.deepEqual(
69
- await testUtils.getActualJson('testExistingQuery', 'query'),
69
+ await testUtils.getActualJson('testExisting_query', 'query'),
70
70
  await testUtils.getExpectedJson('9999999', 'query', 'get'),
71
71
  'returned metadata was not equal expected'
72
72
  );
73
- expect(file(testUtils.getActualFile('testExistingQuery', 'query', 'sql'))).to.equal(
73
+ expect(file(testUtils.getActualFile('testExisting_query', 'query', 'sql'))).to.equal(
74
74
  file(testUtils.getExpectedFile('9999999', 'query', 'get', 'sql'))
75
75
  );
76
76
  assert.equal(
@@ -80,6 +80,61 @@ describe('type: query', () => {
80
80
  );
81
81
  return;
82
82
  });
83
+ it('Should retrieve one specific query via --like', async () => {
84
+ // WHEN
85
+ handler.setOptions({ like: { key: '%Existing_query' } });
86
+ await handler.retrieve('testInstance/testBU', ['query']);
87
+ // THEN
88
+ assert.equal(process.exitCode, false, 'retrieve should not have thrown an error');
89
+ // get results from cache
90
+ const result = cache.getCache();
91
+ assert.equal(
92
+ result.query ? Object.keys(result.query).length : 0,
93
+ 3,
94
+ 'three queries in cache expected'
95
+ );
96
+ assert.deepEqual(
97
+ await testUtils.getActualJson('testExisting_query', 'query'),
98
+ await testUtils.getExpectedJson('9999999', 'query', 'get'),
99
+ 'returned metadata was not equal expected'
100
+ );
101
+ expect(file(testUtils.getActualFile('testExisting_query', 'query', 'sql'))).to.equal(
102
+ file(testUtils.getExpectedFile('9999999', 'query', 'get', 'sql'))
103
+ );
104
+ expect(file(testUtils.getActualFile('testExisting_query2', 'query', 'sql'))).to.not
105
+ .exist;
106
+ assert.equal(
107
+ testUtils.getAPIHistoryLength(),
108
+ 6,
109
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
110
+ );
111
+ return;
112
+ });
113
+ it('Should not retrieve any query via --like and key due to a mismatching filter', async () => {
114
+ // WHEN
115
+ handler.setOptions({ like: { key: 'NotExisting_query' } });
116
+ await handler.retrieve('testInstance/testBU', ['query']);
117
+ // THEN
118
+ assert.equal(process.exitCode, false, 'retrieve should not have thrown an error');
119
+ // get results from cache
120
+ const result = cache.getCache();
121
+ assert.equal(
122
+ result.query ? Object.keys(result.query).length : 0,
123
+ 3,
124
+ 'three queries in cache expected'
125
+ );
126
+
127
+ expect(file(testUtils.getActualFile('testExisting_query', 'query', 'sql'))).to.not
128
+ .exist;
129
+ expect(file(testUtils.getActualFile('testExisting_query2', 'query', 'sql'))).to.not
130
+ .exist;
131
+ assert.equal(
132
+ testUtils.getAPIHistoryLength(),
133
+ 6,
134
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
135
+ );
136
+ return;
137
+ });
83
138
  });
84
139
  describe('Deploy ================', () => {
85
140
  beforeEach(() => {
@@ -87,32 +142,43 @@ describe('type: query', () => {
87
142
  });
88
143
  it('Should create & upsert a query', async () => {
89
144
  // WHEN
90
- await handler.deploy('testInstance/testBU', ['query']);
145
+ const resultDeploy = await handler.deploy(
146
+ 'testInstance/testBU',
147
+ ['query'],
148
+ ['testNew_query', 'testExisting_query']
149
+ );
91
150
  // THEN
92
151
  assert.equal(process.exitCode, false, 'deploy should not have thrown an error');
152
+ assert.equal(
153
+ resultDeploy['testInstance/testBU']?.query
154
+ ? Object.keys(resultDeploy['testInstance/testBU']?.query).length
155
+ : 0,
156
+ 2,
157
+ 'two queries to be deployed'
158
+ );
93
159
  // get results from cache
94
160
  const result = cache.getCache();
95
161
  assert.equal(
96
162
  result.query ? Object.keys(result.query).length : 0,
97
- 3,
98
- 'three queries expected'
163
+ 4,
164
+ 'four queries expected in cache'
99
165
  );
100
166
  // confirm created item
101
167
  assert.deepEqual(
102
- await testUtils.getActualJson('testNewQuery', 'query'),
168
+ await testUtils.getActualJson('testNew_query', 'query'),
103
169
  await testUtils.getExpectedJson('9999999', 'query', 'post'),
104
170
  'returned metadata was not equal expected for insert query'
105
171
  );
106
- expect(file(testUtils.getActualFile('testNewQuery', 'query', 'sql'))).to.equal(
172
+ expect(file(testUtils.getActualFile('testNew_query', 'query', 'sql'))).to.equal(
107
173
  file(testUtils.getExpectedFile('9999999', 'query', 'post', 'sql'))
108
174
  );
109
175
  // confirm updated item
110
176
  assert.deepEqual(
111
- await testUtils.getActualJson('testExistingQuery', 'query'),
177
+ await testUtils.getActualJson('testExisting_query', 'query'),
112
178
  await testUtils.getExpectedJson('9999999', 'query', 'patch'),
113
179
  'returned metadata was not equal expected for insert query'
114
180
  );
115
- expect(file(testUtils.getActualFile('testExistingQuery', 'query', 'sql'))).to.equal(
181
+ expect(file(testUtils.getActualFile('testExisting_query', 'query', 'sql'))).to.equal(
116
182
  file(testUtils.getExpectedFile('9999999', 'query', 'patch', 'sql'))
117
183
  );
118
184
  // check number of API calls
@@ -123,7 +189,356 @@ describe('type: query', () => {
123
189
  );
124
190
  return;
125
191
  });
126
- it('Should change the key during update with --changeKeyValue');
192
+ it('Should deploy and execute with --execute', async () => {
193
+ handler.setOptions({ execute: true });
194
+ // WHEN
195
+ await handler.deploy(
196
+ 'testInstance/testBU',
197
+ ['query'],
198
+ ['testExisting_query', 'testNew_query']
199
+ );
200
+ // THEN
201
+ assert.equal(
202
+ process.exitCode,
203
+ false,
204
+ 'deploy with --execute should not have thrown an error'
205
+ );
206
+ // confirm updated item
207
+ assert.deepEqual(
208
+ await testUtils.getActualJson('testExisting_query', 'query'),
209
+ await testUtils.getExpectedJson('9999999', 'query', 'patch'),
210
+ 'returned metadata was not equal expected for insert query'
211
+ );
212
+ expect(file(testUtils.getActualFile('testExisting_query', 'query', 'sql'))).to.equal(
213
+ file(testUtils.getExpectedFile('9999999', 'query', 'patch', 'sql'))
214
+ );
215
+ // check number of API calls
216
+ assert.equal(
217
+ testUtils.getAPIHistoryLength(),
218
+ 12,
219
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
220
+ );
221
+ return;
222
+ });
223
+ });
224
+ describe('FixKeys ================', () => {
225
+ beforeEach(() => {
226
+ testUtils.mockSetup(true);
227
+ });
228
+ it('Should change the key during update with --changeKeyValue', async () => {
229
+ // WHEN
230
+ await handler.retrieve(
231
+ 'testInstance/testBU',
232
+ ['query'],
233
+ ['testExisting_query_fixKeys']
234
+ );
235
+ handler.setOptions({
236
+ changeKeyValue: 'testExisting_query_fixedKeys',
237
+ fromRetrieve: true,
238
+ });
239
+ const deployed = await handler.deploy(
240
+ 'testInstance/testBU',
241
+ ['query'],
242
+ ['testExisting_query_fixKeys']
243
+ );
244
+ // THEN
245
+ assert.equal(
246
+ process.exitCode,
247
+ false,
248
+ 'deploy --changeKeyValue should not have thrown an error'
249
+ );
250
+ assert.equal(
251
+ Object.keys(deployed['testInstance/testBU'].query).length,
252
+ 1,
253
+ 'returned number of keys does not correspond to number of expected fixed keys'
254
+ );
255
+ assert.equal(
256
+ Object.keys(deployed['testInstance/testBU'].query)[0],
257
+ 'testExisting_query_fixedKeys',
258
+ 'returned keys do not correspond to expected fixed keys'
259
+ );
260
+
261
+ // confirm updated item
262
+ assert.deepEqual(
263
+ await testUtils.getActualJson('testExisting_query_fixedKeys', 'query'),
264
+ await testUtils.getExpectedJson('9999999', 'query', 'patch_fixKeys'),
265
+ 'returned metadata was not equal expected for update query'
266
+ );
267
+ expect(
268
+ file(testUtils.getActualFile('testExisting_query_fixedKeys', 'query', 'sql'))
269
+ ).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'patch_fixKeys', 'sql')));
270
+ // check number of API calls
271
+ assert.equal(
272
+ testUtils.getAPIHistoryLength(),
273
+ 14,
274
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
275
+ );
276
+ return;
277
+ });
278
+ it('Should change the key during update with --changeKeyField', async () => {
279
+ // WHEN
280
+ await handler.retrieve(
281
+ 'testInstance/testBU',
282
+ ['query'],
283
+ ['testExisting_query_fixKeys']
284
+ );
285
+ handler.setOptions({ changeKeyField: 'name', fromRetrieve: true });
286
+ const deployed = await handler.deploy(
287
+ 'testInstance/testBU',
288
+ ['query'],
289
+ ['testExisting_query_fixKeys']
290
+ );
291
+ // THEN
292
+ assert.equal(
293
+ process.exitCode,
294
+ false,
295
+ 'deploy --changeKeyValue should not have thrown an error'
296
+ );
297
+ assert.equal(
298
+ Object.keys(deployed['testInstance/testBU'].query).length,
299
+ 1,
300
+ 'returned number of keys does not correspond to number of expected fixed keys'
301
+ );
302
+ assert.equal(
303
+ Object.keys(deployed['testInstance/testBU'].query)[0],
304
+ 'testExisting_query_fixedKeys',
305
+ 'returned keys do not correspond to expected fixed keys'
306
+ );
307
+ // confirm updated item
308
+ assert.deepEqual(
309
+ await testUtils.getActualJson('testExisting_query_fixedKeys', 'query'),
310
+ await testUtils.getExpectedJson('9999999', 'query', 'patch_fixKeys'),
311
+ 'returned metadata was not equal expected for update query'
312
+ );
313
+ expect(
314
+ file(testUtils.getActualFile('testExisting_query_fixedKeys', 'query', 'sql'))
315
+ ).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'patch_fixKeys', 'sql')));
316
+ // check number of API calls
317
+ assert.equal(
318
+ testUtils.getAPIHistoryLength(),
319
+ 14,
320
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
321
+ );
322
+ return;
323
+ });
324
+ it('Should run fixKeys but not find fixable keys and hence stop', async () => {
325
+ // WHEN
326
+ handler.setOptions({ skipInteraction: { fixKeysReretrieve: false } });
327
+ const resultFixKeys = await handler.fixKeys('testInstance/testBU', 'query', [
328
+ 'testExisting_query',
329
+ ]);
330
+ // THEN
331
+ assert.equal(process.exitCode, false, 'fixKeys should not have thrown an error');
332
+ // check which keys were fixed
333
+ assert.equal(
334
+ resultFixKeys['testInstance/testBU'].length,
335
+ 0,
336
+ 'expected to find no keys to be fixed'
337
+ );
338
+
339
+ // get results from cache
340
+ const result = cache.getCache();
341
+ assert.equal(
342
+ result.query ? Object.keys(result.query).length : 0,
343
+ 1,
344
+ 'one query expected'
345
+ );
346
+ // check number of API calls
347
+ assert.equal(
348
+ testUtils.getAPIHistoryLength(),
349
+ 7,
350
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
351
+ );
352
+ return;
353
+ });
354
+ it('Should fixKeys by key WITHOUT re-retrieving dependent types', async () => {
355
+ // WHEN
356
+ handler.setOptions({ skipInteraction: { fixKeysReretrieve: false } });
357
+ const resultFixKeys = await handler.fixKeys('testInstance/testBU', 'query', [
358
+ 'testExisting_query_fixKeys',
359
+ 'testExisting_query',
360
+ ]);
361
+ assert.equal(
362
+ resultFixKeys['testInstance/testBU'].length,
363
+ 1,
364
+ 'returned number of keys does not correspond to number of expected fixed keys'
365
+ );
366
+ assert.equal(
367
+ resultFixKeys['testInstance/testBU'][0],
368
+ 'testExisting_query_fixedKeys',
369
+ 'returned keys do not correspond to expected fixed keys'
370
+ );
371
+ // THEN
372
+ assert.equal(process.exitCode, false, 'fixKeys should not have thrown an error');
373
+ // confirm updated item
374
+ assert.deepEqual(
375
+ await testUtils.getActualJson('testExisting_query_fixedKeys', 'query'),
376
+ await testUtils.getExpectedJson('9999999', 'query', 'patch_fixKeys'),
377
+ 'returned metadata was not equal expected for update query'
378
+ );
379
+ expect(
380
+ file(testUtils.getActualFile('testExisting_query_fixedKeys', 'query', 'sql'))
381
+ ).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'patch_fixKeys', 'sql')));
382
+ // check number of API calls
383
+ assert.equal(
384
+ testUtils.getAPIHistoryLength(),
385
+ 16,
386
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
387
+ );
388
+ return;
389
+ });
390
+ it('Should fixKeys by key WITHOUT re-retrieving dependent types and then --execute', async () => {
391
+ // WHEN
392
+ handler.setOptions({ skipInteraction: { fixKeysReretrieve: false }, execute: true });
393
+ const resultFixKeys = await handler.fixKeys('testInstance/testBU', 'query', [
394
+ 'testExisting_query_fixKeys',
395
+ 'testExisting_query',
396
+ ]);
397
+ assert.equal(
398
+ resultFixKeys['testInstance/testBU'].length,
399
+ 1,
400
+ 'returned number of keys does not correspond to number of expected fixed keys'
401
+ );
402
+ assert.equal(
403
+ resultFixKeys['testInstance/testBU'][0],
404
+ 'testExisting_query_fixedKeys',
405
+ 'returned keys do not correspond to expected fixed keys'
406
+ );
407
+ // THEN
408
+ assert.equal(
409
+ process.exitCode,
410
+ false,
411
+ 'fixKeys with --execute should not have thrown an error'
412
+ );
413
+ // confirm updated item
414
+ assert.deepEqual(
415
+ await testUtils.getActualJson('testExisting_query_fixedKeys', 'query'),
416
+ await testUtils.getExpectedJson('9999999', 'query', 'patch_fixKeys'),
417
+ 'returned metadata was not equal expected for update query'
418
+ );
419
+ expect(
420
+ file(testUtils.getActualFile('testExisting_query_fixedKeys', 'query', 'sql'))
421
+ ).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'patch_fixKeys', 'sql')));
422
+ // check number of API calls
423
+ assert.equal(
424
+ testUtils.getAPIHistoryLength(),
425
+ 18,
426
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
427
+ );
428
+ return;
429
+ });
430
+ it('Should fixKeys by key AND re-retrieve dependent types', async () => {
431
+ // WHEN
432
+ handler.setOptions({ skipInteraction: { fixKeysReretrieve: true } });
433
+ const resultFixKeys = await handler.fixKeys('testInstance/testBU', 'query', [
434
+ 'testExisting_query_fixKeys',
435
+ 'testExisting_query',
436
+ ]);
437
+ assert.equal(
438
+ resultFixKeys['testInstance/testBU'].length,
439
+ 1,
440
+ 'returned number of keys does not correspond to number of expected fixed keys'
441
+ );
442
+ assert.equal(
443
+ resultFixKeys['testInstance/testBU'][0],
444
+ 'testExisting_query_fixedKeys',
445
+ 'returned keys do not correspond to expected fixed keys'
446
+ );
447
+ // THEN
448
+ assert.equal(process.exitCode, false, 'fixKeys should not have thrown an error');
449
+ // confirm updated item
450
+ assert.deepEqual(
451
+ await testUtils.getActualJson('testExisting_query_fixedKeys', 'query'),
452
+ await testUtils.getExpectedJson('9999999', 'query', 'patch_fixKeys'),
453
+ 'returned metadata was not equal expected for update query'
454
+ );
455
+ expect(
456
+ file(testUtils.getActualFile('testExisting_query_fixedKeys', 'query', 'sql'))
457
+ ).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'patch_fixKeys', 'sql')));
458
+ // check number of API calls
459
+ assert.equal(
460
+ testUtils.getAPIHistoryLength(),
461
+ 33,
462
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
463
+ );
464
+ return;
465
+ });
466
+ it('Should fixKeys by key AND re-retrieve dependent types and then --execute', async () => {
467
+ // WHEN
468
+ handler.setOptions({ skipInteraction: { fixKeysReretrieve: true }, execute: true });
469
+ const resultFixKeys = await handler.fixKeys('testInstance/testBU', 'query', [
470
+ 'testExisting_query_fixKeys',
471
+ 'testExisting_query',
472
+ ]);
473
+ assert.equal(
474
+ resultFixKeys['testInstance/testBU'].length,
475
+ 1,
476
+ 'returned number of keys does not correspond to number of expected fixed keys'
477
+ );
478
+ assert.equal(
479
+ resultFixKeys['testInstance/testBU'][0],
480
+ 'testExisting_query_fixedKeys',
481
+ 'returned keys do not correspond to expected fixed keys'
482
+ );
483
+ // THEN
484
+ assert.equal(
485
+ process.exitCode,
486
+ false,
487
+ 'fixKeys with --execute should not have thrown an error'
488
+ );
489
+ // confirm updated item
490
+ assert.deepEqual(
491
+ await testUtils.getActualJson('testExisting_query_fixedKeys', 'query'),
492
+ await testUtils.getExpectedJson('9999999', 'query', 'patch_fixKeys'),
493
+ 'returned metadata was not equal expected for update query'
494
+ );
495
+ expect(
496
+ file(testUtils.getActualFile('testExisting_query_fixedKeys', 'query', 'sql'))
497
+ ).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'patch_fixKeys', 'sql')));
498
+ // check number of API calls
499
+ assert.equal(
500
+ testUtils.getAPIHistoryLength(),
501
+ 35,
502
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
503
+ );
504
+ return;
505
+ });
506
+ it('Should fixKeys via --like WITHOUT re-retrieving dependent types', async () => {
507
+ // WHEN
508
+ handler.setOptions({
509
+ like: { key: 'testExisting_query_f%' },
510
+ skipInteraction: { fixKeysReretrieve: false },
511
+ });
512
+ const resultFixKeys = await handler.fixKeys('testInstance/testBU', 'query');
513
+ assert.equal(
514
+ resultFixKeys['testInstance/testBU'].length,
515
+ 1,
516
+ 'returned number of keys does not correspond to number of expected fixed keys'
517
+ );
518
+ assert.equal(
519
+ resultFixKeys['testInstance/testBU'][0],
520
+ 'testExisting_query_fixedKeys',
521
+ 'returned keys do not correspond to expected fixed keys'
522
+ );
523
+ // THEN
524
+ assert.equal(process.exitCode, false, 'fixKeys should not have thrown an error');
525
+ // confirm updated item
526
+ assert.deepEqual(
527
+ await testUtils.getActualJson('testExisting_query_fixedKeys', 'query'),
528
+ await testUtils.getExpectedJson('9999999', 'query', 'patch_fixKeys'),
529
+ 'returned metadata was not equal expected for update query'
530
+ );
531
+ expect(
532
+ file(testUtils.getActualFile('testExisting_query_fixedKeys', 'query', 'sql'))
533
+ ).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'patch_fixKeys', 'sql')));
534
+ // check number of API calls
535
+ assert.equal(
536
+ testUtils.getAPIHistoryLength(),
537
+ 13,
538
+ 'Unexpected number of requests made. Run testUtils.logAPIHistoryDebug() to see the requests'
539
+ );
540
+ return;
541
+ });
127
542
  });
128
543
  describe('Templating ================', () => {
129
544
  it('Should create a query template via retrieveAsTemplate and build it', async () => {
@@ -131,7 +546,7 @@ describe('type: query', () => {
131
546
  const result = await handler.retrieveAsTemplate(
132
547
  'testInstance/testBU',
133
548
  'query',
134
- ['testExistingQuery'],
549
+ ['testExisting_query'],
135
550
  'testSourceMarket'
136
551
  );
137
552
  // WHEN
@@ -146,18 +561,18 @@ describe('type: query', () => {
146
561
  'only one query expected'
147
562
  );
148
563
  assert.deepEqual(
149
- await testUtils.getActualTemplateJson('testExistingQuery', 'query'),
564
+ await testUtils.getActualTemplateJson('testExisting_query', 'query'),
150
565
  await testUtils.getExpectedJson('9999999', 'query', 'template'),
151
566
  'returned template JSON of retrieveAsTemplate was not equal expected'
152
567
  );
153
568
  expect(
154
- file(testUtils.getActualTemplateFile('testExistingQuery', 'query', 'sql'))
569
+ file(testUtils.getActualTemplateFile('testExisting_query', 'query', 'sql'))
155
570
  ).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'template', 'sql')));
156
571
  // THEN
157
572
  await handler.buildDefinition(
158
573
  'testInstance/testBU',
159
574
  'query',
160
- 'testExistingQuery',
575
+ 'testExisting_query',
161
576
  'testTargetMarket'
162
577
  );
163
578
  assert.equal(
@@ -167,13 +582,14 @@ describe('type: query', () => {
167
582
  );
168
583
 
169
584
  assert.deepEqual(
170
- await testUtils.getActualDeployJson('testExistingQuery', 'query'),
585
+ await testUtils.getActualDeployJson('testTemplated_query', 'query'),
171
586
  await testUtils.getExpectedJson('9999999', 'query', 'build'),
172
587
  'returned deployment JSON was not equal expected'
173
588
  );
174
589
  expect(
175
- file(testUtils.getActualDeployFile('testExistingQuery', 'query', 'sql'))
590
+ file(testUtils.getActualDeployFile('testTemplated_query', 'query', 'sql'))
176
591
  ).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'build', 'sql')));
592
+
177
593
  assert.equal(
178
594
  testUtils.getAPIHistoryLength(),
179
595
  6,
@@ -188,7 +604,7 @@ describe('type: query', () => {
188
604
  const result = await handler.buildTemplate(
189
605
  'testInstance/testBU',
190
606
  'query',
191
- ['testExistingQuery'],
607
+ ['testExisting_query'],
192
608
  'testSourceMarket'
193
609
  );
194
610
  // WHEN
@@ -200,18 +616,18 @@ describe('type: query', () => {
200
616
  'only one query expected'
201
617
  );
202
618
  assert.deepEqual(
203
- await testUtils.getActualTemplateJson('testExistingQuery', 'query'),
619
+ await testUtils.getActualTemplateJson('testExisting_query', 'query'),
204
620
  await testUtils.getExpectedJson('9999999', 'query', 'template'),
205
621
  'returned template JSON of buildTemplate was not equal expected'
206
622
  );
207
623
  expect(
208
- file(testUtils.getActualTemplateFile('testExistingQuery', 'query', 'sql'))
624
+ file(testUtils.getActualTemplateFile('testExisting_query', 'query', 'sql'))
209
625
  ).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'template', 'sql')));
210
626
  // THEN
211
627
  await handler.buildDefinition(
212
628
  'testInstance/testBU',
213
629
  'query',
214
- 'testExistingQuery',
630
+ 'testExisting_query',
215
631
  'testTargetMarket'
216
632
  );
217
633
  assert.equal(
@@ -221,12 +637,12 @@ describe('type: query', () => {
221
637
  );
222
638
 
223
639
  assert.deepEqual(
224
- await testUtils.getActualDeployJson('testExistingQuery', 'query'),
640
+ await testUtils.getActualDeployJson('testTemplated_query', 'query'),
225
641
  await testUtils.getExpectedJson('9999999', 'query', 'build'),
226
642
  'returned deployment JSON was not equal expected'
227
643
  );
228
644
  expect(
229
- file(testUtils.getActualDeployFile('testExistingQuery', 'query', 'sql'))
645
+ file(testUtils.getActualDeployFile('testTemplated_query', 'query', 'sql'))
230
646
  ).to.equal(file(testUtils.getExpectedFile('9999999', 'query', 'build', 'sql')));
231
647
 
232
648
  assert.equal(
@@ -241,7 +657,7 @@ describe('type: query', () => {
241
657
  it('Should delete the item', async () => {
242
658
  // WHEN
243
659
  const result = await handler.deleteByKey('testInstance/testBU', 'query', [
244
- 'testExistingQuery',
660
+ 'testExisting_query',
245
661
  ]);
246
662
  // THEN
247
663
  assert.equal(process.exitCode, false, 'delete should not have thrown an error');
@@ -254,7 +670,7 @@ describe('type: query', () => {
254
670
  it('Should return a list of files based on their type and key', async () => {
255
671
  // WHEN
256
672
  const fileList = await handler.getFilesToCommit('testInstance/testBU', 'query', [
257
- 'testExistingQuery',
673
+ 'testExisting_query',
258
674
  ]);
259
675
  // THEN
260
676
  assert.equal(
@@ -266,15 +682,63 @@ describe('type: query', () => {
266
682
 
267
683
  assert.equal(
268
684
  fileList[0].split('\\').join('/'),
269
- 'retrieve/testInstance/testBU/query/testExistingQuery.query-meta.json',
685
+ 'retrieve/testInstance/testBU/query/testExisting_query.query-meta.json',
270
686
  'wrong JSON path'
271
687
  );
272
688
  assert.equal(
273
689
  fileList[1].split('\\').join('/'),
274
- 'retrieve/testInstance/testBU/query/testExistingQuery.query-meta.sql',
690
+ 'retrieve/testInstance/testBU/query/testExisting_query.query-meta.sql',
275
691
  'wrong JSON path'
276
692
  );
277
693
  return;
278
694
  });
279
695
  });
696
+ describe('Execute ================', () => {
697
+ it('Should start a query by key', async () => {
698
+ const executedKeys = await handler.execute('testInstance/testBU', 'query', [
699
+ 'testExisting_query',
700
+ ]);
701
+ assert.equal(process.exitCode, false, 'execute should not have thrown an error');
702
+ assert.equal(
703
+ executedKeys['testInstance/testBU']?.length,
704
+ 1,
705
+ 'returned number of keys does not correspond to number of expected fixed keys'
706
+ );
707
+ assert.equal(
708
+ executedKeys['testInstance/testBU'][0],
709
+ 'testExisting_query',
710
+ 'returned keys do not correspond to expected fixed keys'
711
+ );
712
+ return;
713
+ });
714
+ it('Should start a query selected via --like', async () => {
715
+ handler.setOptions({ like: { key: 'testExist%query' } });
716
+ const executedKeys = await handler.execute('testInstance/testBU', 'query');
717
+ assert.equal(process.exitCode, false, 'execute should not have thrown an error');
718
+ assert.equal(
719
+ executedKeys['testInstance/testBU']?.length,
720
+ 1,
721
+ 'returned number of keys does not correspond to number of expected fixed keys'
722
+ );
723
+ assert.equal(
724
+ executedKeys['testInstance/testBU'][0],
725
+ 'testExisting_query',
726
+ 'returned keys do not correspond to expected fixed keys'
727
+ );
728
+ return;
729
+ });
730
+ it('Should not start executing a query because key and --like was specified', async () => {
731
+ handler.setOptions({ like: { key: 'testExisting%' } });
732
+ const executedKeys = await handler.execute('testInstance/testBU', 'query', [
733
+ 'testExisting_query',
734
+ ]);
735
+ assert.equal(process.exitCode, true, 'execute should have thrown an error');
736
+ assert.equal(
737
+ Object.keys(executedKeys).length,
738
+ 0,
739
+ 'query was not supposed to be executed'
740
+ );
741
+ return;
742
+ });
743
+ });
280
744
  });