@datadog/datadog-ci 2.4.1 → 2.5.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 (185) hide show
  1. package/dist/commands/dsyms/upload.js +2 -1
  2. package/dist/commands/dsyms/upload.js.map +1 -1
  3. package/dist/commands/flutter-symbols/helpers.js +1 -1
  4. package/dist/commands/flutter-symbols/helpers.js.map +1 -1
  5. package/dist/commands/flutter-symbols/upload.js +1 -1
  6. package/dist/commands/flutter-symbols/upload.js.map +1 -1
  7. package/dist/commands/lambda/instrument.js +1 -1
  8. package/dist/commands/lambda/instrument.js.map +1 -1
  9. package/dist/commands/lambda/uninstrument.js +1 -1
  10. package/dist/commands/lambda/uninstrument.js.map +1 -1
  11. package/dist/commands/react-native/upload.js +2 -2
  12. package/dist/commands/react-native/upload.js.map +1 -1
  13. package/dist/commands/react-native/xcode.js +5 -0
  14. package/dist/commands/react-native/xcode.js.map +1 -1
  15. package/dist/commands/synthetics/api.d.ts +2 -1
  16. package/dist/commands/synthetics/api.js +7 -0
  17. package/dist/commands/synthetics/api.js.map +1 -1
  18. package/dist/commands/synthetics/command.js +11 -2
  19. package/dist/commands/synthetics/command.js.map +1 -1
  20. package/dist/commands/synthetics/interfaces.d.ts +4 -1
  21. package/dist/commands/synthetics/reporters/default.d.ts +3 -2
  22. package/dist/commands/synthetics/reporters/default.js +19 -5
  23. package/dist/commands/synthetics/reporters/default.js.map +1 -1
  24. package/dist/commands/synthetics/reporters/junit.d.ts +2 -2
  25. package/dist/commands/synthetics/reporters/junit.js +1 -1
  26. package/dist/commands/synthetics/reporters/junit.js.map +1 -1
  27. package/dist/commands/synthetics/run-test.js +9 -1
  28. package/dist/commands/synthetics/run-test.js.map +1 -1
  29. package/dist/commands/synthetics/utils.d.ts +4 -2
  30. package/dist/commands/synthetics/utils.js +14 -5
  31. package/dist/commands/synthetics/utils.js.map +1 -1
  32. package/dist/helpers/utils.d.ts +2 -2
  33. package/dist/helpers/utils.js +9 -5
  34. package/dist/helpers/utils.js.map +1 -1
  35. package/package.json +3 -3
  36. package/dist/commands/dsyms/__tests__/upload.test.d.ts +0 -1
  37. package/dist/commands/dsyms/__tests__/upload.test.js +0 -297
  38. package/dist/commands/dsyms/__tests__/upload.test.js.map +0 -1
  39. package/dist/commands/dsyms/__tests__/utils.test.d.ts +0 -1
  40. package/dist/commands/dsyms/__tests__/utils.test.js +0 -99
  41. package/dist/commands/dsyms/__tests__/utils.test.js.map +0 -1
  42. package/dist/commands/flutter-symbols/__tests__/upload.test.d.ts +0 -1
  43. package/dist/commands/flutter-symbols/__tests__/upload.test.js +0 -538
  44. package/dist/commands/flutter-symbols/__tests__/upload.test.js.map +0 -1
  45. package/dist/commands/git-metadata/__tests__/git.test.d.ts +0 -1
  46. package/dist/commands/git-metadata/__tests__/git.test.js +0 -148
  47. package/dist/commands/git-metadata/__tests__/git.test.js.map +0 -1
  48. package/dist/commands/git-metadata/__tests__/library.test.d.ts +0 -1
  49. package/dist/commands/git-metadata/__tests__/library.test.js +0 -103
  50. package/dist/commands/git-metadata/__tests__/library.test.js.map +0 -1
  51. package/dist/commands/git-metadata/__tests__/upload.test.d.ts +0 -1
  52. package/dist/commands/git-metadata/__tests__/upload.test.js +0 -60
  53. package/dist/commands/git-metadata/__tests__/upload.test.js.map +0 -1
  54. package/dist/commands/junit/__tests__/api.test.d.ts +0 -1
  55. package/dist/commands/junit/__tests__/api.test.js +0 -9
  56. package/dist/commands/junit/__tests__/api.test.js.map +0 -1
  57. package/dist/commands/junit/__tests__/upload.test.d.ts +0 -1
  58. package/dist/commands/junit/__tests__/upload.test.js +0 -283
  59. package/dist/commands/junit/__tests__/upload.test.js.map +0 -1
  60. package/dist/commands/lambda/__tests__/fixtures.d.ts +0 -49
  61. package/dist/commands/lambda/__tests__/fixtures.js +0 -88
  62. package/dist/commands/lambda/__tests__/fixtures.js.map +0 -1
  63. package/dist/commands/lambda/__tests__/functions/commons.test.d.ts +0 -1
  64. package/dist/commands/lambda/__tests__/functions/commons.test.js +0 -716
  65. package/dist/commands/lambda/__tests__/functions/commons.test.js.map +0 -1
  66. package/dist/commands/lambda/__tests__/functions/instrument.part1.test.d.ts +0 -1
  67. package/dist/commands/lambda/__tests__/functions/instrument.part1.test.js +0 -350
  68. package/dist/commands/lambda/__tests__/functions/instrument.part1.test.js.map +0 -1
  69. package/dist/commands/lambda/__tests__/functions/instrument.part2.test.d.ts +0 -1
  70. package/dist/commands/lambda/__tests__/functions/instrument.part2.test.js +0 -583
  71. package/dist/commands/lambda/__tests__/functions/instrument.part2.test.js.map +0 -1
  72. package/dist/commands/lambda/__tests__/functions/uninstrument.test.d.ts +0 -1
  73. package/dist/commands/lambda/__tests__/functions/uninstrument.test.js +0 -477
  74. package/dist/commands/lambda/__tests__/functions/uninstrument.test.js.map +0 -1
  75. package/dist/commands/lambda/__tests__/functions/versionChecker.test.d.ts +0 -1
  76. package/dist/commands/lambda/__tests__/functions/versionChecker.test.js +0 -33
  77. package/dist/commands/lambda/__tests__/functions/versionChecker.test.js.map +0 -1
  78. package/dist/commands/lambda/__tests__/instrument.test.d.ts +0 -1
  79. package/dist/commands/lambda/__tests__/instrument.test.js +0 -1478
  80. package/dist/commands/lambda/__tests__/instrument.test.js.map +0 -1
  81. package/dist/commands/lambda/__tests__/loggroup.test.d.ts +0 -1
  82. package/dist/commands/lambda/__tests__/loggroup.test.js +0 -332
  83. package/dist/commands/lambda/__tests__/loggroup.test.js.map +0 -1
  84. package/dist/commands/lambda/__tests__/prompt.test.d.ts +0 -1
  85. package/dist/commands/lambda/__tests__/prompt.test.js +0 -235
  86. package/dist/commands/lambda/__tests__/prompt.test.js.map +0 -1
  87. package/dist/commands/lambda/__tests__/tags.test.d.ts +0 -1
  88. package/dist/commands/lambda/__tests__/tags.test.js +0 -253
  89. package/dist/commands/lambda/__tests__/tags.test.js.map +0 -1
  90. package/dist/commands/lambda/__tests__/uninstrument.test.d.ts +0 -1
  91. package/dist/commands/lambda/__tests__/uninstrument.test.js +0 -679
  92. package/dist/commands/lambda/__tests__/uninstrument.test.js.map +0 -1
  93. package/dist/commands/metric/__tests__/metric.test.d.ts +0 -1
  94. package/dist/commands/metric/__tests__/metric.test.js +0 -97
  95. package/dist/commands/metric/__tests__/metric.test.js.map +0 -1
  96. package/dist/commands/react-native/__tests__/codepush.test.d.ts +0 -1
  97. package/dist/commands/react-native/__tests__/codepush.test.js +0 -153
  98. package/dist/commands/react-native/__tests__/codepush.test.js.map +0 -1
  99. package/dist/commands/react-native/__tests__/interfaces.test.d.ts +0 -1
  100. package/dist/commands/react-native/__tests__/interfaces.test.js +0 -52
  101. package/dist/commands/react-native/__tests__/interfaces.test.js.map +0 -1
  102. package/dist/commands/react-native/__tests__/upload.test.d.ts +0 -1
  103. package/dist/commands/react-native/__tests__/upload.test.js +0 -176
  104. package/dist/commands/react-native/__tests__/upload.test.js.map +0 -1
  105. package/dist/commands/react-native/__tests__/xcode.test.d.ts +0 -1
  106. package/dist/commands/react-native/__tests__/xcode.test.js +0 -417
  107. package/dist/commands/react-native/__tests__/xcode.test.js.map +0 -1
  108. package/dist/commands/sourcemaps/__tests__/upload.test.d.ts +0 -1
  109. package/dist/commands/sourcemaps/__tests__/upload.test.js +0 -270
  110. package/dist/commands/sourcemaps/__tests__/upload.test.js.map +0 -1
  111. package/dist/commands/sourcemaps/__tests__/utils.test.d.ts +0 -1
  112. package/dist/commands/sourcemaps/__tests__/utils.test.js +0 -31
  113. package/dist/commands/sourcemaps/__tests__/utils.test.js.map +0 -1
  114. package/dist/commands/synthetics/__tests__/api.test.d.ts +0 -1
  115. package/dist/commands/synthetics/__tests__/api.test.js +0 -273
  116. package/dist/commands/synthetics/__tests__/api.test.js.map +0 -1
  117. package/dist/commands/synthetics/__tests__/cli.test.d.ts +0 -1
  118. package/dist/commands/synthetics/__tests__/cli.test.js +0 -391
  119. package/dist/commands/synthetics/__tests__/cli.test.js.map +0 -1
  120. package/dist/commands/synthetics/__tests__/fixtures.d.ts +0 -119
  121. package/dist/commands/synthetics/__tests__/fixtures.js +0 -386
  122. package/dist/commands/synthetics/__tests__/fixtures.js.map +0 -1
  123. package/dist/commands/synthetics/__tests__/mobile.test.d.ts +0 -1
  124. package/dist/commands/synthetics/__tests__/mobile.test.js +0 -228
  125. package/dist/commands/synthetics/__tests__/mobile.test.js.map +0 -1
  126. package/dist/commands/synthetics/__tests__/reporters/default.test.d.ts +0 -1
  127. package/dist/commands/synthetics/__tests__/reporters/default.test.js +0 -202
  128. package/dist/commands/synthetics/__tests__/reporters/default.test.js.map +0 -1
  129. package/dist/commands/synthetics/__tests__/reporters/junit.test.d.ts +0 -1
  130. package/dist/commands/synthetics/__tests__/reporters/junit.test.js +0 -339
  131. package/dist/commands/synthetics/__tests__/reporters/junit.test.js.map +0 -1
  132. package/dist/commands/synthetics/__tests__/run-test.test.d.ts +0 -1
  133. package/dist/commands/synthetics/__tests__/run-test.test.js +0 -419
  134. package/dist/commands/synthetics/__tests__/run-test.test.js.map +0 -1
  135. package/dist/commands/synthetics/__tests__/tunnel/crypto.test.d.ts +0 -1
  136. package/dist/commands/synthetics/__tests__/tunnel/crypto.test.js +0 -21
  137. package/dist/commands/synthetics/__tests__/tunnel/crypto.test.js.map +0 -1
  138. package/dist/commands/synthetics/__tests__/tunnel/tunnel.test.d.ts +0 -1
  139. package/dist/commands/synthetics/__tests__/tunnel/tunnel.test.js +0 -80
  140. package/dist/commands/synthetics/__tests__/tunnel/tunnel.test.js.map +0 -1
  141. package/dist/commands/synthetics/__tests__/tunnel/websocket.test.d.ts +0 -1
  142. package/dist/commands/synthetics/__tests__/tunnel/websocket.test.js +0 -111
  143. package/dist/commands/synthetics/__tests__/tunnel/websocket.test.js.map +0 -1
  144. package/dist/commands/synthetics/__tests__/utils.test.d.ts +0 -1
  145. package/dist/commands/synthetics/__tests__/utils.test.js +0 -933
  146. package/dist/commands/synthetics/__tests__/utils.test.js.map +0 -1
  147. package/dist/commands/tag/__tests__/tag.test.d.ts +0 -1
  148. package/dist/commands/tag/__tests__/tag.test.js +0 -77
  149. package/dist/commands/tag/__tests__/tag.test.js.map +0 -1
  150. package/dist/commands/trace/__tests__/trace.test.d.ts +0 -1
  151. package/dist/commands/trace/__tests__/trace.test.js +0 -64
  152. package/dist/commands/trace/__tests__/trace.test.js.map +0 -1
  153. package/dist/helpers/__tests__/ci.test.d.ts +0 -1
  154. package/dist/helpers/__tests__/ci.test.js +0 -197
  155. package/dist/helpers/__tests__/ci.test.js.map +0 -1
  156. package/dist/helpers/__tests__/plist.test.d.ts +0 -1
  157. package/dist/helpers/__tests__/plist.test.js +0 -31
  158. package/dist/helpers/__tests__/plist.test.js.map +0 -1
  159. package/dist/helpers/__tests__/retry.test.d.ts +0 -1
  160. package/dist/helpers/__tests__/retry.test.js +0 -99
  161. package/dist/helpers/__tests__/retry.test.js.map +0 -1
  162. package/dist/helpers/__tests__/tags.test.d.ts +0 -1
  163. package/dist/helpers/__tests__/tags.test.js +0 -17
  164. package/dist/helpers/__tests__/tags.test.js.map +0 -1
  165. package/dist/helpers/__tests__/upload.test.d.ts +0 -1
  166. package/dist/helpers/__tests__/upload.test.js +0 -185
  167. package/dist/helpers/__tests__/upload.test.js.map +0 -1
  168. package/dist/helpers/__tests__/user-provided-git.test.d.ts +0 -1
  169. package/dist/helpers/__tests__/user-provided-git.test.js +0 -119
  170. package/dist/helpers/__tests__/user-provided-git.test.js.map +0 -1
  171. package/dist/helpers/__tests__/utils.test.d.ts +0 -1
  172. package/dist/helpers/__tests__/utils.test.js +0 -382
  173. package/dist/helpers/__tests__/utils.test.js.map +0 -1
  174. package/dist/helpers/__tests__/validation.test.d.ts +0 -1
  175. package/dist/helpers/__tests__/validation.test.js +0 -21
  176. package/dist/helpers/__tests__/validation.test.js.map +0 -1
  177. package/dist/helpers/git/__tests__/format-git-sourcemaps-data.test.d.ts +0 -1
  178. package/dist/helpers/git/__tests__/format-git-sourcemaps-data.test.js +0 -106
  179. package/dist/helpers/git/__tests__/format-git-sourcemaps-data.test.js.map +0 -1
  180. package/dist/helpers/git/__tests__/format-git-span-data.test.d.ts +0 -1
  181. package/dist/helpers/git/__tests__/format-git-span-data.test.js +0 -67
  182. package/dist/helpers/git/__tests__/format-git-span-data.test.js.map +0 -1
  183. package/dist/helpers/git/__tests__/get-git-data.test.d.ts +0 -1
  184. package/dist/helpers/git/__tests__/get-git-data.test.js +0 -60
  185. package/dist/helpers/git/__tests__/get-git-data.test.js.map +0 -1
@@ -1,679 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
- return new (P || (P = Promise))(function (resolve, reject) {
24
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
- step((generator = generator.apply(thisArg, _arguments || [])).next());
28
- });
29
- };
30
- Object.defineProperty(exports, "__esModule", { value: true });
31
- jest.mock('fs');
32
- jest.mock('aws-sdk');
33
- jest.mock('../prompt');
34
- jest.mock('../renderer', () => require('../__mocks__/renderer'));
35
- const fs = __importStar(require("fs"));
36
- const aws_sdk_1 = require("aws-sdk");
37
- const constants_1 = require("../constants");
38
- const prompt_1 = require("../prompt");
39
- const uninstrument_1 = require("../uninstrument");
40
- const fixtures_1 = require("./fixtures");
41
- describe('lambda', () => {
42
- describe('uninstrument', () => {
43
- describe('execute', () => {
44
- const OLD_ENV = process.env;
45
- beforeEach(() => {
46
- jest.resetModules();
47
- process.env = {};
48
- });
49
- afterAll(() => {
50
- process.env = OLD_ENV;
51
- });
52
- test('prints dry run data for a valid uninstrumentation', () => __awaiter(void 0, void 0, void 0, function* () {
53
- ;
54
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
55
- aws_sdk_1.Lambda.mockImplementation(() => fixtures_1.makeMockLambda({
56
- 'arn:aws:lambda:us-east-1:000000000000:function:uninstrument': {
57
- Architectures: ['x86_64'],
58
- Environment: {
59
- Variables: {
60
- [constants_1.ENVIRONMENT_ENV_VAR]: 'staging',
61
- [constants_1.FLUSH_TO_LOG_ENV_VAR]: 'true',
62
- [constants_1.LAMBDA_HANDLER_ENV_VAR]: 'lambda_function.lambda_handler',
63
- [constants_1.LOG_LEVEL_ENV_VAR]: 'debug',
64
- [constants_1.MERGE_XRAY_TRACES_ENV_VAR]: 'false',
65
- [constants_1.SERVICE_ENV_VAR]: 'middletier',
66
- [constants_1.SITE_ENV_VAR]: 'datadoghq.com',
67
- [constants_1.TRACE_ENABLED_ENV_VAR]: 'true',
68
- [constants_1.VERSION_ENV_VAR]: '0.2',
69
- USER_VARIABLE: 'shouldnt be deleted by uninstrumentation',
70
- },
71
- },
72
- FunctionArn: 'arn:aws:lambda:us-east-1:000000000000:function:uninstrument',
73
- Handler: 'datadog_lambda.handler.handler',
74
- Layers: [
75
- {
76
- Arn: 'arn:aws:lambda:sa-east-1:000000000000:layer:Datadog-Extension:11',
77
- CodeSize: 0,
78
- SigningJobArn: 'some-signing-job-arn',
79
- SigningProfileVersionArn: 'some-signing-profile',
80
- },
81
- {
82
- Arn: 'arn:aws:lambda:sa-east-1:000000000000:layer:Datadog-Python38:49',
83
- CodeSize: 0,
84
- SigningJobArn: 'some-signing-job-arn',
85
- SigningProfileVersionArn: 'some-signing-profile',
86
- },
87
- ],
88
- Runtime: 'python3.8',
89
- },
90
- }));
91
- const cli = fixtures_1.makeCli();
92
- const context = fixtures_1.createMockContext();
93
- const functionARN = 'arn:aws:lambda:us-east-1:000000000000:function:uninstrument';
94
- process.env.DATADOG_API_KEY = '1234';
95
- const code = yield cli.run(['lambda', 'uninstrument', '-f', functionARN, '-r', 'us-east-1', '-d'], context);
96
- const output = context.stdout.toString();
97
- expect(code).toBe(0);
98
- expect(output).toMatchInlineSnapshot(`
99
- "
100
- [Dry Run] 🐶 Uninstrumenting Lambda function
101
-
102
- [!] Functions to be updated:
103
- - arn:aws:lambda:us-east-1:000000000000:function:uninstrument
104
-
105
- [Dry Run] Will apply the following updates:
106
- UpdateFunctionConfiguration -> arn:aws:lambda:us-east-1:000000000000:function:uninstrument
107
- {
108
- \\"FunctionName\\": \\"arn:aws:lambda:us-east-1:000000000000:function:uninstrument\\",
109
- \\"Handler\\": \\"lambda_function.lambda_handler\\",
110
- \\"Environment\\": {
111
- \\"Variables\\": {
112
- \\"USER_VARIABLE\\": \\"shouldnt be deleted by uninstrumentation\\"
113
- }
114
- },
115
- \\"Layers\\": []
116
- }
117
- "
118
- `);
119
- }));
120
- test('runs function update command for valid uninstrumentation', () => __awaiter(void 0, void 0, void 0, function* () {
121
- ;
122
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
123
- const lambda = fixtures_1.makeMockLambda({
124
- 'arn:aws:lambda:us-east-1:000000000000:function:uninstrument': {
125
- Environment: {
126
- Variables: {
127
- [constants_1.ENVIRONMENT_ENV_VAR]: 'staging',
128
- [constants_1.FLUSH_TO_LOG_ENV_VAR]: 'true',
129
- [constants_1.LAMBDA_HANDLER_ENV_VAR]: 'lambda_function.lambda_handler',
130
- [constants_1.LOG_LEVEL_ENV_VAR]: 'debug',
131
- [constants_1.MERGE_XRAY_TRACES_ENV_VAR]: 'false',
132
- [constants_1.SERVICE_ENV_VAR]: 'middletier',
133
- [constants_1.SITE_ENV_VAR]: 'datadoghq.com',
134
- [constants_1.TRACE_ENABLED_ENV_VAR]: 'true',
135
- [constants_1.VERSION_ENV_VAR]: '0.2',
136
- USER_VARIABLE: 'shouldnt be deleted by uninstrumentation',
137
- },
138
- },
139
- FunctionArn: 'arn:aws:lambda:us-east-1:000000000000:function:uninstrument',
140
- Handler: 'datadog_lambda.handler.handler',
141
- Layers: [
142
- {
143
- Arn: 'arn:aws:lambda:sa-east-1:000000000000:layer:Datadog-Extension:11',
144
- CodeSize: 0,
145
- SigningJobArn: 'some-signing-job-arn',
146
- SigningProfileVersionArn: 'some-signing-profile',
147
- },
148
- {
149
- Arn: 'arn:aws:lambda:sa-east-1:000000000000:layer:Datadog-Python38:49',
150
- CodeSize: 0,
151
- SigningJobArn: 'some-signing-job-arn',
152
- SigningProfileVersionArn: 'some-signing-profile',
153
- },
154
- ],
155
- Runtime: 'python3.8',
156
- },
157
- });
158
- aws_sdk_1.Lambda.mockImplementation(() => lambda);
159
- const cli = fixtures_1.makeCli();
160
- const context = fixtures_1.createMockContext();
161
- const functionARN = 'arn:aws:lambda:us-east-1:000000000000:function:uninstrument';
162
- process.env.DATADOG_API_KEY = '1234';
163
- yield cli.run(['lambda', 'uninstrument', '-f', functionARN, '-r', 'us-east-1'], context);
164
- expect(lambda.updateFunctionConfiguration).toHaveBeenCalled();
165
- }));
166
- test('aborts early when the aws-sdk throws an error', () => __awaiter(void 0, void 0, void 0, function* () {
167
- ;
168
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
169
- aws_sdk_1.Lambda.mockImplementation(() => ({
170
- getFunction: jest.fn().mockImplementation(() => ({ promise: () => Promise.reject('Lambda failed') })),
171
- }));
172
- process.env = {};
173
- const command = fixtures_1.createCommand(uninstrument_1.UninstrumentCommand);
174
- command['functions'] = ['my-func'];
175
- command['region'] = 'us-east-1';
176
- const code = yield command['execute']();
177
- const output = command.context.stdout.toString();
178
- expect(code).toBe(1);
179
- expect(output).toMatch("[Error] Couldn't fetch Lambda functions. Lambda failed\n");
180
- }));
181
- test("aborts early when function regions can't be found", () => __awaiter(void 0, void 0, void 0, function* () {
182
- ;
183
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
184
- aws_sdk_1.Lambda.mockImplementation(() => fixtures_1.makeMockLambda({}));
185
- const cli = fixtures_1.makeCli();
186
- const context = fixtures_1.createMockContext();
187
- const code = yield cli.run(['lambda', 'uninstrument', '--function', 'my-func'], context);
188
- const output = context.stdout.toString();
189
- expect(code).toBe(1);
190
- expect(output).toMatch('No default region specified for ["my-func"]. Use -r, --region, or use a full functionARN');
191
- }));
192
- test('aborts early when no functions are specified', () => __awaiter(void 0, void 0, void 0, function* () {
193
- ;
194
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
195
- aws_sdk_1.Lambda.mockImplementation(() => fixtures_1.makeMockLambda({}));
196
- const cli = fixtures_1.makeCli();
197
- const context = fixtures_1.createMockContext();
198
- const code = yield cli.run(['lambda', 'uninstrument'], context);
199
- const output = context.stdout.toString();
200
- expect(code).toBe(1);
201
- expect(output).toMatchInlineSnapshot(`
202
- "
203
- 🐶 Uninstrumenting Lambda function
204
- [Error] No functions specified to remove instrumentation.
205
- "
206
- `);
207
- }));
208
- test('aborts early when no functions are specified while using config file', () => __awaiter(void 0, void 0, void 0, function* () {
209
- ;
210
- fs.readFile.mockImplementation((a, b, callback) => callback({}));
211
- process.env = {};
212
- const command = fixtures_1.createCommand(uninstrument_1.UninstrumentCommand);
213
- command['config']['region'] = 'ap-southeast-1';
214
- yield command['execute']();
215
- const output = command.context.stdout.toString();
216
- expect(output).toMatchInlineSnapshot(`
217
- "
218
- 🐶 Uninstrumenting Lambda function
219
- [Error] No functions specified to remove instrumentation.
220
- "
221
- `);
222
- }));
223
- test('aborts if functions and a pattern are set at the same time', () => __awaiter(void 0, void 0, void 0, function* () {
224
- ;
225
- fs.readFile.mockImplementation((a, b, callback) => callback({}));
226
- process.env = {};
227
- let command = fixtures_1.createCommand(uninstrument_1.UninstrumentCommand);
228
- command['config']['region'] = 'ap-southeast-1';
229
- command['config']['functions'] = ['arn:aws:lambda:ap-southeast-1:123456789012:function:lambda-hello-world'];
230
- command['regExPattern'] = 'valid-pattern';
231
- yield command['execute']();
232
- let output = command.context.stdout.toString();
233
- expect(output).toMatch('Functions in config file and "--functions-regex" should not be used at the same time.\n');
234
- command = fixtures_1.createCommand(uninstrument_1.UninstrumentCommand);
235
- command['region'] = 'ap-southeast-1';
236
- command['functions'] = ['arn:aws:lambda:ap-southeast-1:123456789012:function:lambda-hello-world'];
237
- command['regExPattern'] = 'valid-pattern';
238
- yield command['execute']();
239
- output = command.context.stdout.toString();
240
- expect(output).toMatch('"--functions" and "--functions-regex" should not be used at the same time.\n');
241
- }));
242
- test('aborts if the regEx pattern is an ARN', () => __awaiter(void 0, void 0, void 0, function* () {
243
- ;
244
- fs.readFile.mockImplementation((a, b, callback) => callback({}));
245
- process.env = {};
246
- const command = fixtures_1.createCommand(uninstrument_1.UninstrumentCommand);
247
- command['region'] = 'ap-southeast-1';
248
- command['regExPattern'] = 'arn:aws:lambda:ap-southeast-1:123456789012:function:*';
249
- const code = yield command['execute']();
250
- const output = command.context.stdout.toString();
251
- expect(code).toBe(1);
252
- expect(output).toMatch(`"--functions-regex" isn't meant to be used with ARNs.\n`);
253
- }));
254
- test('aborts if the regEx pattern is set but no region is specified', () => __awaiter(void 0, void 0, void 0, function* () {
255
- ;
256
- fs.readFile.mockImplementation((a, b, callback) => callback({}));
257
- process.env = {};
258
- const command = fixtures_1.createCommand(uninstrument_1.UninstrumentCommand);
259
- command['regExPattern'] = 'my-function';
260
- const code = yield command['execute']();
261
- const output = command.context.stdout.toString();
262
- expect(code).toBe(1);
263
- expect(output).toMatch('No default region specified. Use `-r`, `--region`.');
264
- }));
265
- test('aborts if the the aws-sdk fails', () => __awaiter(void 0, void 0, void 0, function* () {
266
- ;
267
- fs.readFile.mockImplementation((a, b, callback) => callback({}));
268
- aws_sdk_1.Lambda.mockImplementation(() => ({
269
- listFunctions: jest.fn().mockImplementation(() => ({ promise: () => Promise.reject('ListFunctionsError') })),
270
- }));
271
- process.env = {};
272
- aws_sdk_1.Lambda.mockImplementation(() => ({
273
- listFunctions: jest.fn().mockImplementation(() => ({ promise: () => Promise.reject('ListFunctionsError') })),
274
- }));
275
- const command = fixtures_1.createCommand(uninstrument_1.UninstrumentCommand);
276
- command['region'] = 'ap-southeast-1';
277
- command['regExPattern'] = 'my-function';
278
- const code = yield command['execute']();
279
- const output = command.context.stdout.toString();
280
- expect(code).toBe(1);
281
- expect(output).toMatch("\n[Error] Couldn't fetch Lambda functions. Error: Max retry count exceeded. ListFunctionsError\n");
282
- }));
283
- test('uninstrument multiple functions interactively', () => __awaiter(void 0, void 0, void 0, function* () {
284
- ;
285
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
286
- aws_sdk_1.Lambda.mockImplementation(() => fixtures_1.makeMockLambda({
287
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world': {
288
- Architectures: ['x86_64'],
289
- Environment: {
290
- Variables: {
291
- [constants_1.ENVIRONMENT_ENV_VAR]: 'staging',
292
- [constants_1.FLUSH_TO_LOG_ENV_VAR]: 'true',
293
- [constants_1.LAMBDA_HANDLER_ENV_VAR]: 'lambda_function.lambda_handler',
294
- [constants_1.LOG_LEVEL_ENV_VAR]: 'debug',
295
- [constants_1.MERGE_XRAY_TRACES_ENV_VAR]: 'false',
296
- [constants_1.SERVICE_ENV_VAR]: 'middletier',
297
- [constants_1.SITE_ENV_VAR]: 'datadoghq.com',
298
- [constants_1.TRACE_ENABLED_ENV_VAR]: 'true',
299
- [constants_1.VERSION_ENV_VAR]: '0.2',
300
- USER_VARIABLE: 'shouldnt be deleted by uninstrumentation',
301
- },
302
- },
303
- FunctionArn: 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world',
304
- FunctionName: 'lambda-hello-world',
305
- Handler: 'datadog_lambda.handler.handler',
306
- Layers: [
307
- {
308
- Arn: 'arn:aws:lambda:sa-east-1:000000000000:layer:Datadog-Extension:11',
309
- CodeSize: 0,
310
- SigningJobArn: 'some-signing-job-arn',
311
- SigningProfileVersionArn: 'some-signing-profile',
312
- },
313
- {
314
- Arn: 'arn:aws:lambda:sa-east-1:000000000000:layer:Datadog-Python38:49',
315
- CodeSize: 0,
316
- SigningJobArn: 'some-signing-job-arn',
317
- SigningProfileVersionArn: 'some-signing-profile',
318
- },
319
- ],
320
- Runtime: 'python3.8',
321
- },
322
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-2': {
323
- Architectures: ['x86_64'],
324
- Environment: {
325
- Variables: {
326
- [constants_1.ENVIRONMENT_ENV_VAR]: 'staging',
327
- [constants_1.FLUSH_TO_LOG_ENV_VAR]: 'true',
328
- [constants_1.LAMBDA_HANDLER_ENV_VAR]: 'lambda_function.lambda_handler',
329
- [constants_1.LOG_LEVEL_ENV_VAR]: 'debug',
330
- [constants_1.MERGE_XRAY_TRACES_ENV_VAR]: 'false',
331
- [constants_1.SERVICE_ENV_VAR]: 'middletier',
332
- [constants_1.SITE_ENV_VAR]: 'datadoghq.com',
333
- [constants_1.TRACE_ENABLED_ENV_VAR]: 'true',
334
- [constants_1.VERSION_ENV_VAR]: '0.2',
335
- },
336
- },
337
- FunctionArn: 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-2',
338
- FunctionName: 'lambda-hello-world-2',
339
- Handler: 'datadog_lambda.handler.handler',
340
- Layers: [
341
- {
342
- Arn: 'arn:aws:lambda:sa-east-1:000000000000:layer:Datadog-Extension:11',
343
- CodeSize: 0,
344
- SigningJobArn: 'some-signing-job-arn',
345
- SigningProfileVersionArn: 'some-signing-profile',
346
- },
347
- {
348
- Arn: 'arn:aws:lambda:sa-east-1:000000000000:layer:Datadog-Python39:49',
349
- CodeSize: 0,
350
- SigningJobArn: 'some-signing-job-arn',
351
- SigningProfileVersionArn: 'some-signing-profile',
352
- },
353
- ],
354
- Runtime: 'python3.9',
355
- },
356
- }));
357
- prompt_1.requestAWSCredentials.mockImplementation(() => {
358
- process.env[constants_1.AWS_ACCESS_KEY_ID_ENV_VAR] = fixtures_1.mockAwsAccessKeyId;
359
- process.env[constants_1.AWS_SECRET_ACCESS_KEY_ENV_VAR] = fixtures_1.mockAwsSecretAccessKey;
360
- process.env[constants_1.AWS_DEFAULT_REGION_ENV_VAR] = 'sa-east-1';
361
- });
362
- prompt_1.requestFunctionSelection.mockImplementation(() => [
363
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world',
364
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-2',
365
- ]);
366
- prompt_1.requestChangesConfirmation.mockImplementation(() => true);
367
- const cli = fixtures_1.makeCli();
368
- const context = fixtures_1.createMockContext();
369
- const code = yield cli.run(['lambda', 'uninstrument', '-i'], context);
370
- const output = context.stdout.toString();
371
- expect(code).toBe(0);
372
- expect(output).toMatchSnapshot();
373
- }));
374
- test('uninstrument multiple specified functions interactively', () => __awaiter(void 0, void 0, void 0, function* () {
375
- ;
376
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
377
- aws_sdk_1.Lambda.mockImplementation(() => fixtures_1.makeMockLambda({
378
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world': {
379
- Architectures: ['x86_64'],
380
- Environment: {
381
- Variables: {
382
- [constants_1.ENVIRONMENT_ENV_VAR]: 'staging',
383
- [constants_1.FLUSH_TO_LOG_ENV_VAR]: 'true',
384
- [constants_1.LAMBDA_HANDLER_ENV_VAR]: 'lambda_function.lambda_handler',
385
- [constants_1.LOG_LEVEL_ENV_VAR]: 'debug',
386
- [constants_1.MERGE_XRAY_TRACES_ENV_VAR]: 'false',
387
- [constants_1.SERVICE_ENV_VAR]: 'middletier',
388
- [constants_1.SITE_ENV_VAR]: 'datadoghq.com',
389
- [constants_1.TRACE_ENABLED_ENV_VAR]: 'true',
390
- [constants_1.VERSION_ENV_VAR]: '0.2',
391
- USER_VARIABLE: 'shouldnt be deleted by uninstrumentation',
392
- },
393
- },
394
- FunctionArn: 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world',
395
- FunctionName: 'lambda-hello-world',
396
- Handler: 'datadog_lambda.handler.handler',
397
- Layers: [
398
- {
399
- Arn: 'arn:aws:lambda:sa-east-1:000000000000:layer:Datadog-Extension:11',
400
- CodeSize: 0,
401
- SigningJobArn: 'some-signing-job-arn',
402
- SigningProfileVersionArn: 'some-signing-profile',
403
- },
404
- {
405
- Arn: 'arn:aws:lambda:sa-east-1:000000000000:layer:Datadog-Python38:49',
406
- CodeSize: 0,
407
- SigningJobArn: 'some-signing-job-arn',
408
- SigningProfileVersionArn: 'some-signing-profile',
409
- },
410
- ],
411
- Runtime: 'python3.8',
412
- },
413
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-2': {
414
- Architectures: ['x86_64'],
415
- Environment: {
416
- Variables: {
417
- [constants_1.ENVIRONMENT_ENV_VAR]: 'staging',
418
- [constants_1.FLUSH_TO_LOG_ENV_VAR]: 'true',
419
- [constants_1.LAMBDA_HANDLER_ENV_VAR]: 'lambda_function.lambda_handler',
420
- [constants_1.LOG_LEVEL_ENV_VAR]: 'debug',
421
- [constants_1.MERGE_XRAY_TRACES_ENV_VAR]: 'false',
422
- [constants_1.SERVICE_ENV_VAR]: 'middletier',
423
- [constants_1.SITE_ENV_VAR]: 'datadoghq.com',
424
- [constants_1.TRACE_ENABLED_ENV_VAR]: 'true',
425
- [constants_1.VERSION_ENV_VAR]: '0.2',
426
- },
427
- },
428
- FunctionArn: 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-2',
429
- FunctionName: 'lambda-hello-world-2',
430
- Handler: 'datadog_lambda.handler.handler',
431
- Layers: [
432
- {
433
- Arn: 'arn:aws:lambda:sa-east-1:000000000000:layer:Datadog-Extension:11',
434
- CodeSize: 0,
435
- SigningJobArn: 'some-signing-job-arn',
436
- SigningProfileVersionArn: 'some-signing-profile',
437
- },
438
- {
439
- Arn: 'arn:aws:lambda:sa-east-1:000000000000:layer:Datadog-Python39:49',
440
- CodeSize: 0,
441
- SigningJobArn: 'some-signing-job-arn',
442
- SigningProfileVersionArn: 'some-signing-profile',
443
- },
444
- ],
445
- Runtime: 'python3.9',
446
- },
447
- }));
448
- prompt_1.requestAWSCredentials.mockImplementation(() => {
449
- process.env[constants_1.AWS_ACCESS_KEY_ID_ENV_VAR] = fixtures_1.mockAwsAccessKeyId;
450
- process.env[constants_1.AWS_SECRET_ACCESS_KEY_ENV_VAR] = fixtures_1.mockAwsSecretAccessKey;
451
- process.env[constants_1.AWS_DEFAULT_REGION_ENV_VAR] = 'sa-east-1';
452
- });
453
- prompt_1.requestFunctionSelection.mockImplementation(() => [
454
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world',
455
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-2',
456
- ]);
457
- prompt_1.requestChangesConfirmation.mockImplementation(() => true);
458
- const cli = fixtures_1.makeCli();
459
- const context = fixtures_1.createMockContext();
460
- const code = yield cli.run([
461
- 'lambda',
462
- 'uninstrument',
463
- '-i',
464
- '-f',
465
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world',
466
- '-f',
467
- 'arn:aws:lambda:sa-east-1:123456789012:function:lambda-hello-world-2',
468
- ], context);
469
- const output = context.stdout.toString();
470
- expect(code).toBe(0);
471
- expect(output).toMatchSnapshot();
472
- }));
473
- test('aborts if a problem occurs while setting the AWS credentials interactively', () => __awaiter(void 0, void 0, void 0, function* () {
474
- ;
475
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
476
- prompt_1.requestAWSCredentials.mockImplementation(() => Promise.reject('Unexpected error'));
477
- const cli = fixtures_1.makeCli();
478
- const context = fixtures_1.createMockContext();
479
- const code = yield cli.run(['lambda', 'uninstrument', '-i'], context);
480
- const output = context.stdout.toString();
481
- expect(code).toBe(1);
482
- expect(output).toMatchInlineSnapshot(`
483
- "
484
- 🐶 Uninstrumenting Lambda function
485
- [!] No AWS credentials found, let's set them up! Or you can re-run the command and supply the AWS credentials in the same way when you invoke the AWS CLI.
486
- [Error] Unexpected error
487
- "
488
- `);
489
- }));
490
- test('aborts if there are no functions to uninstrument in the user AWS account', () => __awaiter(void 0, void 0, void 0, function* () {
491
- process.env = {
492
- [constants_1.AWS_ACCESS_KEY_ID_ENV_VAR]: fixtures_1.mockAwsAccessKeyId,
493
- [constants_1.AWS_SECRET_ACCESS_KEY_ENV_VAR]: fixtures_1.mockAwsSecretAccessKey,
494
- [constants_1.AWS_DEFAULT_REGION_ENV_VAR]: 'sa-east-1',
495
- };
496
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
497
- aws_sdk_1.Lambda.mockImplementation(() => fixtures_1.makeMockLambda({}));
498
- const cli = fixtures_1.makeCli();
499
- const context = fixtures_1.createMockContext();
500
- const code = yield cli.run(['lambda', 'uninstrument', '-i'], context);
501
- const output = context.stdout.toString();
502
- expect(code).toBe(1);
503
- expect(output).toMatchInlineSnapshot(`
504
- "
505
- 🐶 Uninstrumenting Lambda function
506
- [Error] Couldn't find any Lambda functions in the specified region.
507
- "
508
- `);
509
- }));
510
- test('aborts early when the aws-sdk throws an error while uninstrumenting interactively', () => __awaiter(void 0, void 0, void 0, function* () {
511
- process.env = {
512
- [constants_1.AWS_ACCESS_KEY_ID_ENV_VAR]: fixtures_1.mockAwsAccessKeyId,
513
- [constants_1.AWS_SECRET_ACCESS_KEY_ENV_VAR]: fixtures_1.mockAwsSecretAccessKey,
514
- [constants_1.AWS_DEFAULT_REGION_ENV_VAR]: 'sa-east-1',
515
- };
516
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
517
- aws_sdk_1.Lambda.mockImplementation(() => ({
518
- listFunctions: jest.fn().mockImplementation(() => ({ promise: () => Promise.reject('ListFunctionsError') })),
519
- }));
520
- const cli = fixtures_1.makeCli();
521
- const context = fixtures_1.createMockContext();
522
- const code = yield cli.run(['lambda', 'uninstrument', '-i'], context);
523
- const output = context.stdout.toString();
524
- expect(code).toBe(1);
525
- expect(output).toMatchInlineSnapshot(`
526
- "
527
- 🐶 Uninstrumenting Lambda function
528
- [Error] Couldn't fetch Lambda functions. Error: Max retry count exceeded. ListFunctionsError
529
- "
530
- `);
531
- }));
532
- test('prints error when updating aws profile credentials fails', () => __awaiter(void 0, void 0, void 0, function* () {
533
- ;
534
- aws_sdk_1.SharedIniFileCredentials.mockImplementation(() => {
535
- throw Error('Update failed!');
536
- });
537
- const cli = fixtures_1.makeCli();
538
- const context = fixtures_1.createMockContext();
539
- const functionARN = 'arn:aws:lambda:us-east-1:123456789012:function:lambda-hello-world';
540
- const code = yield cli.run(['lambda', 'uninstrument', '-f', functionARN, '--profile', 'SOME-AWS-PROFILE'], context);
541
- const output = context.stdout.toString();
542
- expect(code).toBe(1);
543
- expect(output).toMatchInlineSnapshot(`
544
- "
545
- 🐶 Uninstrumenting Lambda function
546
- [Error] Error: Couldn't set AWS profile credentials. Update failed!
547
- "
548
- `);
549
- }));
550
- test('prints which functions failed to uninstrument without aborting when at least one function was uninstrumented correctly', () => __awaiter(void 0, void 0, void 0, function* () {
551
- ;
552
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
553
- const failingLambdas = [
554
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-1-us-east-1',
555
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-2-us-east-1',
556
- 'arn:aws:lambda:us-east-2:123456789012:function:lambda-1-us-east-2',
557
- ];
558
- aws_sdk_1.Lambda.mockImplementation(() => (Object.assign(Object.assign({}, fixtures_1.makeMockLambda({
559
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-1-us-east-1': {
560
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-1-us-east-1',
561
- FunctionName: 'lambda-1-us-east-1',
562
- Handler: 'index.handler',
563
- Runtime: 'nodejs12.x',
564
- },
565
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-2-us-east-1': {
566
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-2-us-east-1',
567
- FunctionName: 'lambda-2-us-east-1',
568
- Handler: 'index.handler',
569
- Runtime: 'nodejs12.x',
570
- },
571
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-3-us-east-1': {
572
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-3-us-east-1',
573
- FunctionName: 'lambda-3-us-east-1',
574
- Handler: 'index.handler',
575
- Runtime: 'nodejs12.x',
576
- },
577
- 'arn:aws:lambda:us-east-2:123456789012:function:lambda-1-us-east-2': {
578
- FunctionArn: 'arn:aws:lambda:us-east-2:123456789012:function:lambda-1-us-east-2',
579
- FunctionName: 'lambda-1-us-east-2',
580
- Handler: 'index.handler',
581
- Runtime: 'nodejs14.x',
582
- },
583
- 'arn:aws:lambda:us-east-2:123456789012:function:lambda-2-us-east-2': {
584
- FunctionArn: 'arn:aws:lambda:us-east-2:123456789012:function:lambda-2-us-east-2',
585
- FunctionName: 'lambda-2-us-east-2',
586
- Handler: 'index.handler',
587
- Runtime: 'nodejs16.x',
588
- },
589
- 'arn:aws:lambda:us-east-2:123456789012:function:lambda-3-us-east-2': {
590
- FunctionArn: 'arn:aws:lambda:us-east-2:123456789012:function:lambda-3-us-east-2',
591
- FunctionName: 'lambda-3-us-east-2',
592
- Handler: 'index.handler',
593
- Runtime: 'nodejs18.x',
594
- },
595
- })), { updateFunctionConfiguration: jest.fn().mockImplementation((updateRequest) => {
596
- if (failingLambdas.includes(updateRequest['FunctionName'])) {
597
- return { promise: () => Promise.reject(Error('Unexpected error updating request')) };
598
- }
599
- return { promise: () => Promise.resolve() };
600
- }) })));
601
- const cli = fixtures_1.makeCli();
602
- const context = fixtures_1.createMockContext();
603
- const code = yield cli.run([
604
- 'lambda',
605
- 'instrument',
606
- '-f',
607
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-1-us-east-1',
608
- '-f',
609
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-2-us-east-1',
610
- '-f',
611
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-3-us-east-1',
612
- '-f',
613
- 'arn:aws:lambda:us-east-2:123456789012:function:lambda-1-us-east-2',
614
- '-f',
615
- 'arn:aws:lambda:us-east-2:123456789012:function:lambda-2-us-east-2',
616
- '-f',
617
- 'arn:aws:lambda:us-east-2:123456789012:function:lambda-3-us-east-2',
618
- ], context);
619
- const output = context.stdout.toString();
620
- expect(code).toBe(0);
621
- expect(output).toMatchSnapshot();
622
- }));
623
- test('aborts when every lambda function fails to update on uninstrument', () => __awaiter(void 0, void 0, void 0, function* () {
624
- ;
625
- fs.readFile.mockImplementation((a, b, callback) => callback({ code: 'ENOENT' }));
626
- const failingLambdas = [
627
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-1-us-east-1',
628
- 'arn:aws:lambda:us-east-2:123456789012:function:lambda-1-us-east-2',
629
- ];
630
- aws_sdk_1.Lambda.mockImplementation(() => (Object.assign(Object.assign({}, fixtures_1.makeMockLambda({
631
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-1-us-east-1': {
632
- FunctionArn: 'arn:aws:lambda:us-east-1:123456789012:function:lambda-1-us-east-1',
633
- FunctionName: 'lambda-1-us-east-1',
634
- Handler: 'index.handler',
635
- Runtime: 'nodejs12.x',
636
- },
637
- 'arn:aws:lambda:us-east-2:123456789012:function:lambda-1-us-east-2': {
638
- FunctionArn: 'arn:aws:lambda:us-east-2:123456789012:function:lambda-1-us-east-2',
639
- FunctionName: 'lambda-1-us-east-2',
640
- Handler: 'index.handler',
641
- Runtime: 'nodejs14.x',
642
- },
643
- })), { updateFunctionConfiguration: jest.fn().mockImplementation((updateRequest) => {
644
- if (failingLambdas.includes(updateRequest['FunctionName'])) {
645
- return { promise: () => Promise.reject(Error('Unexpected error updating request')) };
646
- }
647
- return { promise: () => Promise.resolve() };
648
- }) })));
649
- const cli = fixtures_1.makeCli();
650
- const context = fixtures_1.createMockContext();
651
- const code = yield cli.run([
652
- 'lambda',
653
- 'instrument',
654
- '-f',
655
- 'arn:aws:lambda:us-east-1:123456789012:function:lambda-1-us-east-1',
656
- '-f',
657
- 'arn:aws:lambda:us-east-2:123456789012:function:lambda-1-us-east-2',
658
- ], context);
659
- const output = context.stdout.toString();
660
- expect(code).toBe(1);
661
- expect(output).toMatchSnapshot();
662
- }));
663
- });
664
- describe('printPlannedActions', () => {
665
- test('prints no output when list is empty', () => {
666
- process.env = {};
667
- const command = fixtures_1.createCommand(uninstrument_1.UninstrumentCommand);
668
- command['printPlannedActions']([]);
669
- const output = command.context.stdout.toString();
670
- expect(output).toMatchInlineSnapshot(`
671
- "
672
- No updates will be applied.
673
- "
674
- `);
675
- });
676
- });
677
- });
678
- });
679
- //# sourceMappingURL=uninstrument.test.js.map