@datadog/datadog-ci 2.40.2 → 2.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/commands/deployment/cli.js +2 -1
- package/dist/commands/deployment/cli.js.map +1 -1
- package/dist/commands/deployment/correlate.d.ts +18 -0
- package/dist/commands/deployment/correlate.js +154 -0
- package/dist/commands/deployment/correlate.js.map +1 -0
- package/dist/commands/dsyms/upload.js +3 -3
- package/dist/commands/dsyms/upload.js.map +1 -1
- package/dist/commands/dsyms/utils.js +2 -4
- package/dist/commands/dsyms/utils.js.map +1 -1
- package/dist/commands/elf-symbols/upload.js +3 -2
- package/dist/commands/elf-symbols/upload.js.map +1 -1
- package/dist/commands/flutter-symbols/upload.js +2 -2
- package/dist/commands/flutter-symbols/upload.js.map +1 -1
- package/dist/commands/junit/upload.js +3 -5
- package/dist/commands/junit/upload.js.map +1 -1
- package/dist/commands/sarif/upload.js +2 -2
- package/dist/commands/sarif/upload.js.map +1 -1
- package/dist/commands/sourcemaps/upload.js +2 -2
- package/dist/commands/sourcemaps/upload.js.map +1 -1
- package/dist/commands/synthetics/utils/public.js +2 -2
- package/dist/commands/synthetics/utils/public.js.map +1 -1
- package/dist/commands/unity-symbols/upload.js +2 -2
- package/dist/commands/unity-symbols/upload.js.map +1 -1
- package/dist/helpers/git/get-git-data.d.ts +2 -0
- package/dist/helpers/git/get-git-data.js +11 -1
- package/dist/helpers/git/get-git-data.js.map +1 -1
- package/package.json +5 -4
- package/dist/__tests__/cli.test.d.ts +0 -1
- package/dist/__tests__/cli.test.js +0 -41
- package/dist/__tests__/cli.test.js.map +0 -1
- package/dist/commands/cloud-run/__tests__/fixtures.d.ts +0 -2
- package/dist/commands/cloud-run/__tests__/fixtures.js +0 -12
- package/dist/commands/cloud-run/__tests__/fixtures.js.map +0 -1
- package/dist/commands/cloud-run/__tests__/flare.test.d.ts +0 -1
- package/dist/commands/cloud-run/__tests__/flare.test.js +0 -557
- package/dist/commands/cloud-run/__tests__/flare.test.js.map +0 -1
- package/dist/commands/deployment/__tests__/mark.test.d.ts +0 -1
- package/dist/commands/deployment/__tests__/mark.test.js +0 -47
- package/dist/commands/deployment/__tests__/mark.test.js.map +0 -1
- package/dist/commands/dora/__tests__/deployment.test.d.ts +0 -1
- package/dist/commands/dora/__tests__/deployment.test.js +0 -201
- package/dist/commands/dora/__tests__/deployment.test.js.map +0 -1
- package/dist/commands/dsyms/__tests__/upload.test.d.ts +0 -1
- package/dist/commands/dsyms/__tests__/upload.test.js +0 -346
- package/dist/commands/dsyms/__tests__/upload.test.js.map +0 -1
- package/dist/commands/dsyms/__tests__/utils.test.d.ts +0 -1
- package/dist/commands/dsyms/__tests__/utils.test.js +0 -100
- package/dist/commands/dsyms/__tests__/utils.test.js.map +0 -1
- package/dist/commands/elf-symbols/__tests__/elf.test.d.ts +0 -1
- package/dist/commands/elf-symbols/__tests__/elf.test.js +0 -813
- package/dist/commands/elf-symbols/__tests__/elf.test.js.map +0 -1
- package/dist/commands/elf-symbols/__tests__/upload.test.d.ts +0 -1
- package/dist/commands/elf-symbols/__tests__/upload.test.js +0 -249
- package/dist/commands/elf-symbols/__tests__/upload.test.js.map +0 -1
- package/dist/commands/flutter-symbols/__tests__/upload.test.d.ts +0 -1
- package/dist/commands/flutter-symbols/__tests__/upload.test.js +0 -617
- package/dist/commands/flutter-symbols/__tests__/upload.test.js.map +0 -1
- package/dist/commands/gate/__tests__/evaluate.test.d.ts +0 -1
- package/dist/commands/gate/__tests__/evaluate.test.js +0 -398
- package/dist/commands/gate/__tests__/evaluate.test.js.map +0 -1
- package/dist/commands/gate/__tests__/scope.test.d.ts +0 -1
- package/dist/commands/gate/__tests__/scope.test.js +0 -29
- package/dist/commands/gate/__tests__/scope.test.js.map +0 -1
- package/dist/commands/git-metadata/__tests__/git.test.d.ts +0 -1
- package/dist/commands/git-metadata/__tests__/git.test.js +0 -132
- package/dist/commands/git-metadata/__tests__/git.test.js.map +0 -1
- package/dist/commands/git-metadata/__tests__/gitdb.test.d.ts +0 -1
- package/dist/commands/git-metadata/__tests__/gitdb.test.js +0 -1386
- package/dist/commands/git-metadata/__tests__/gitdb.test.js.map +0 -1
- package/dist/commands/git-metadata/__tests__/library.test.d.ts +0 -1
- package/dist/commands/git-metadata/__tests__/library.test.js +0 -118
- package/dist/commands/git-metadata/__tests__/library.test.js.map +0 -1
- package/dist/commands/git-metadata/__tests__/upload.test.d.ts +0 -1
- package/dist/commands/git-metadata/__tests__/upload.test.js +0 -52
- package/dist/commands/git-metadata/__tests__/upload.test.js.map +0 -1
- package/dist/commands/junit/__tests__/id.test.d.ts +0 -1
- package/dist/commands/junit/__tests__/id.test.js +0 -24
- package/dist/commands/junit/__tests__/id.test.js.map +0 -1
- package/dist/commands/junit/__tests__/upload.test.d.ts +0 -1
- package/dist/commands/junit/__tests__/upload.test.js +0 -495
- package/dist/commands/junit/__tests__/upload.test.js.map +0 -1
- package/dist/commands/lambda/__tests__/fixtures.d.ts +0 -51
- package/dist/commands/lambda/__tests__/fixtures.js +0 -146
- package/dist/commands/lambda/__tests__/fixtures.js.map +0 -1
- package/dist/commands/lambda/__tests__/flare.test.d.ts +0 -1
- package/dist/commands/lambda/__tests__/flare.test.js +0 -730
- package/dist/commands/lambda/__tests__/flare.test.js.map +0 -1
- package/dist/commands/lambda/__tests__/functions/commons.test.d.ts +0 -1
- package/dist/commands/lambda/__tests__/functions/commons.test.js +0 -791
- package/dist/commands/lambda/__tests__/functions/commons.test.js.map +0 -1
- package/dist/commands/lambda/__tests__/functions/instrument.part1.test.d.ts +0 -1
- package/dist/commands/lambda/__tests__/functions/instrument.part1.test.js +0 -386
- package/dist/commands/lambda/__tests__/functions/instrument.part1.test.js.map +0 -1
- package/dist/commands/lambda/__tests__/functions/instrument.part2.test.d.ts +0 -1
- package/dist/commands/lambda/__tests__/functions/instrument.part2.test.js +0 -721
- package/dist/commands/lambda/__tests__/functions/instrument.part2.test.js.map +0 -1
- package/dist/commands/lambda/__tests__/functions/uninstrument.test.d.ts +0 -1
- package/dist/commands/lambda/__tests__/functions/uninstrument.test.js +0 -513
- package/dist/commands/lambda/__tests__/functions/uninstrument.test.js.map +0 -1
- package/dist/commands/lambda/__tests__/functions/versionChecker.test.d.ts +0 -1
- package/dist/commands/lambda/__tests__/functions/versionChecker.test.js +0 -33
- package/dist/commands/lambda/__tests__/functions/versionChecker.test.js.map +0 -1
- package/dist/commands/lambda/__tests__/instrument.test.d.ts +0 -1
- package/dist/commands/lambda/__tests__/instrument.test.js +0 -1511
- package/dist/commands/lambda/__tests__/instrument.test.js.map +0 -1
- package/dist/commands/lambda/__tests__/loggroup.test.d.ts +0 -1
- package/dist/commands/lambda/__tests__/loggroup.test.js +0 -340
- package/dist/commands/lambda/__tests__/loggroup.test.js.map +0 -1
- package/dist/commands/lambda/__tests__/prompt.test.d.ts +0 -1
- package/dist/commands/lambda/__tests__/prompt.test.js +0 -206
- package/dist/commands/lambda/__tests__/prompt.test.js.map +0 -1
- package/dist/commands/lambda/__tests__/tags.test.d.ts +0 -1
- package/dist/commands/lambda/__tests__/tags.test.js +0 -305
- package/dist/commands/lambda/__tests__/tags.test.js.map +0 -1
- package/dist/commands/lambda/__tests__/uninstrument.test.d.ts +0 -1
- package/dist/commands/lambda/__tests__/uninstrument.test.js +0 -722
- package/dist/commands/lambda/__tests__/uninstrument.test.js.map +0 -1
- package/dist/commands/measure/__tests__/measure.test.d.ts +0 -1
- package/dist/commands/measure/__tests__/measure.test.js +0 -110
- package/dist/commands/measure/__tests__/measure.test.js.map +0 -1
- package/dist/commands/react-native/__tests__/codepush.test.d.ts +0 -1
- package/dist/commands/react-native/__tests__/codepush.test.js +0 -161
- package/dist/commands/react-native/__tests__/codepush.test.js.map +0 -1
- package/dist/commands/react-native/__tests__/interfaces.test.d.ts +0 -1
- package/dist/commands/react-native/__tests__/interfaces.test.js +0 -33
- package/dist/commands/react-native/__tests__/interfaces.test.js.map +0 -1
- package/dist/commands/react-native/__tests__/upload.test.d.ts +0 -1
- package/dist/commands/react-native/__tests__/upload.test.js +0 -238
- package/dist/commands/react-native/__tests__/upload.test.js.map +0 -1
- package/dist/commands/react-native/__tests__/utils.test.d.ts +0 -1
- package/dist/commands/react-native/__tests__/utils.test.js +0 -27
- package/dist/commands/react-native/__tests__/utils.test.js.map +0 -1
- package/dist/commands/react-native/__tests__/xcode.test.d.ts +0 -1
- package/dist/commands/react-native/__tests__/xcode.test.js +0 -465
- package/dist/commands/react-native/__tests__/xcode.test.js.map +0 -1
- package/dist/commands/sarif/__tests__/upload.test.d.ts +0 -1
- package/dist/commands/sarif/__tests__/upload.test.js +0 -228
- package/dist/commands/sarif/__tests__/upload.test.js.map +0 -1
- package/dist/commands/sbom/__tests__/payload.test.d.ts +0 -1
- package/dist/commands/sbom/__tests__/payload.test.js +0 -262
- package/dist/commands/sbom/__tests__/payload.test.js.map +0 -1
- package/dist/commands/sbom/__tests__/validation.test.d.ts +0 -1
- package/dist/commands/sbom/__tests__/validation.test.js +0 -41
- package/dist/commands/sbom/__tests__/validation.test.js.map +0 -1
- package/dist/commands/sourcemaps/__tests__/upload.test.d.ts +0 -1
- package/dist/commands/sourcemaps/__tests__/upload.test.js +0 -270
- package/dist/commands/sourcemaps/__tests__/upload.test.js.map +0 -1
- package/dist/commands/sourcemaps/__tests__/utils.test.d.ts +0 -1
- package/dist/commands/sourcemaps/__tests__/utils.test.js +0 -31
- package/dist/commands/sourcemaps/__tests__/utils.test.js.map +0 -1
- package/dist/commands/stepfunctions/__tests__/awsCommands.test.d.ts +0 -1
- package/dist/commands/stepfunctions/__tests__/awsCommands.test.js +0 -192
- package/dist/commands/stepfunctions/__tests__/awsCommands.test.js.map +0 -1
- package/dist/commands/stepfunctions/__tests__/fixtures/aws-resources.d.ts +0 -6
- package/dist/commands/stepfunctions/__tests__/fixtures/aws-resources.js +0 -45
- package/dist/commands/stepfunctions/__tests__/fixtures/aws-resources.js.map +0 -1
- package/dist/commands/stepfunctions/__tests__/fixtures/cli.d.ts +0 -5
- package/dist/commands/stepfunctions/__tests__/fixtures/cli.js +0 -19
- package/dist/commands/stepfunctions/__tests__/fixtures/cli.js.map +0 -1
- package/dist/commands/stepfunctions/__tests__/helpers.test.d.ts +0 -1
- package/dist/commands/stepfunctions/__tests__/helpers.test.js +0 -205
- package/dist/commands/stepfunctions/__tests__/helpers.test.js.map +0 -1
- package/dist/commands/stepfunctions/__tests__/instrument.test.d.ts +0 -1
- package/dist/commands/stepfunctions/__tests__/instrument.test.js +0 -431
- package/dist/commands/stepfunctions/__tests__/instrument.test.js.map +0 -1
- package/dist/commands/stepfunctions/__tests__/uninstrument.test.d.ts +0 -1
- package/dist/commands/stepfunctions/__tests__/uninstrument.test.js +0 -166
- package/dist/commands/stepfunctions/__tests__/uninstrument.test.js.map +0 -1
- package/dist/commands/synthetics/__tests__/api.test.d.ts +0 -1
- package/dist/commands/synthetics/__tests__/api.test.js +0 -422
- package/dist/commands/synthetics/__tests__/api.test.js.map +0 -1
- package/dist/commands/synthetics/__tests__/cli.test.d.ts +0 -1
- package/dist/commands/synthetics/__tests__/cli.test.js +0 -1325
- package/dist/commands/synthetics/__tests__/cli.test.js.map +0 -1
- package/dist/commands/synthetics/__tests__/fixtures.d.ts +0 -149
- package/dist/commands/synthetics/__tests__/fixtures.js +0 -507
- package/dist/commands/synthetics/__tests__/fixtures.js.map +0 -1
- package/dist/commands/synthetics/__tests__/mobile.test.d.ts +0 -1
- package/dist/commands/synthetics/__tests__/mobile.test.js +0 -376
- package/dist/commands/synthetics/__tests__/mobile.test.js.map +0 -1
- package/dist/commands/synthetics/__tests__/reporters/default.test.d.ts +0 -1
- package/dist/commands/synthetics/__tests__/reporters/default.test.js +0 -354
- package/dist/commands/synthetics/__tests__/reporters/default.test.js.map +0 -1
- package/dist/commands/synthetics/__tests__/reporters/junit.test.d.ts +0 -1
- package/dist/commands/synthetics/__tests__/reporters/junit.test.js +0 -353
- package/dist/commands/synthetics/__tests__/reporters/junit.test.js.map +0 -1
- package/dist/commands/synthetics/__tests__/reporters/mobile/app-upload.test.d.ts +0 -1
- package/dist/commands/synthetics/__tests__/reporters/mobile/app-upload.test.js +0 -232
- package/dist/commands/synthetics/__tests__/reporters/mobile/app-upload.test.js.map +0 -1
- package/dist/commands/synthetics/__tests__/run-tests-lib.test.d.ts +0 -1
- package/dist/commands/synthetics/__tests__/run-tests-lib.test.js +0 -735
- package/dist/commands/synthetics/__tests__/run-tests-lib.test.js.map +0 -1
- package/dist/commands/synthetics/__tests__/test.test.d.ts +0 -1
- package/dist/commands/synthetics/__tests__/test.test.js +0 -33
- package/dist/commands/synthetics/__tests__/test.test.js.map +0 -1
- package/dist/commands/synthetics/__tests__/tunnel/crypto.test.d.ts +0 -1
- package/dist/commands/synthetics/__tests__/tunnel/crypto.test.js +0 -21
- package/dist/commands/synthetics/__tests__/tunnel/crypto.test.js.map +0 -1
- package/dist/commands/synthetics/__tests__/tunnel/tunnel.test.d.ts +0 -1
- package/dist/commands/synthetics/__tests__/tunnel/tunnel.test.js +0 -80
- package/dist/commands/synthetics/__tests__/tunnel/tunnel.test.js.map +0 -1
- package/dist/commands/synthetics/__tests__/tunnel/websocket.test.d.ts +0 -1
- package/dist/commands/synthetics/__tests__/tunnel/websocket.test.js +0 -109
- package/dist/commands/synthetics/__tests__/tunnel/websocket.test.js.map +0 -1
- package/dist/commands/synthetics/__tests__/utils/internal.test.d.ts +0 -1
- package/dist/commands/synthetics/__tests__/utils/internal.test.js +0 -186
- package/dist/commands/synthetics/__tests__/utils/internal.test.js.map +0 -1
- package/dist/commands/synthetics/__tests__/utils/public.test.d.ts +0 -1
- package/dist/commands/synthetics/__tests__/utils/public.test.js +0 -1526
- package/dist/commands/synthetics/__tests__/utils/public.test.js.map +0 -1
- package/dist/commands/tag/__tests__/tag.test.d.ts +0 -1
- package/dist/commands/tag/__tests__/tag.test.js +0 -75
- package/dist/commands/tag/__tests__/tag.test.js.map +0 -1
- package/dist/commands/trace/__tests__/trace.test.d.ts +0 -1
- package/dist/commands/trace/__tests__/trace.test.js +0 -145
- package/dist/commands/trace/__tests__/trace.test.js.map +0 -1
- package/dist/commands/unity-symbols/__tests__/upload.test.d.ts +0 -1
- package/dist/commands/unity-symbols/__tests__/upload.test.js +0 -369
- package/dist/commands/unity-symbols/__tests__/upload.test.js.map +0 -1
- package/dist/helpers/__tests__/app.test.d.ts +0 -1
- package/dist/helpers/__tests__/app.test.js +0 -31
- package/dist/helpers/__tests__/app.test.js.map +0 -1
- package/dist/helpers/__tests__/ci.test.d.ts +0 -1
- package/dist/helpers/__tests__/ci.test.js +0 -252
- package/dist/helpers/__tests__/ci.test.js.map +0 -1
- package/dist/helpers/__tests__/fixtures.d.ts +0 -33
- package/dist/helpers/__tests__/fixtures.js +0 -71
- package/dist/helpers/__tests__/fixtures.js.map +0 -1
- package/dist/helpers/__tests__/flare.test.d.ts +0 -1
- package/dist/helpers/__tests__/flare.test.js +0 -226
- package/dist/helpers/__tests__/flare.test.js.map +0 -1
- package/dist/helpers/__tests__/fs.test.d.ts +0 -1
- package/dist/helpers/__tests__/fs.test.js +0 -189
- package/dist/helpers/__tests__/fs.test.js.map +0 -1
- package/dist/helpers/__tests__/plist.test.d.ts +0 -1
- package/dist/helpers/__tests__/plist.test.js +0 -43
- package/dist/helpers/__tests__/plist.test.js.map +0 -1
- package/dist/helpers/__tests__/prompt.test.d.ts +0 -1
- package/dist/helpers/__tests__/prompt.test.js +0 -71
- package/dist/helpers/__tests__/prompt.test.js.map +0 -1
- package/dist/helpers/__tests__/retry.test.d.ts +0 -1
- package/dist/helpers/__tests__/retry.test.js +0 -99
- package/dist/helpers/__tests__/retry.test.js.map +0 -1
- package/dist/helpers/__tests__/tags.test.d.ts +0 -1
- package/dist/helpers/__tests__/tags.test.js +0 -71
- package/dist/helpers/__tests__/tags.test.js.map +0 -1
- package/dist/helpers/__tests__/upload.test.d.ts +0 -1
- package/dist/helpers/__tests__/upload.test.js +0 -231
- package/dist/helpers/__tests__/upload.test.js.map +0 -1
- package/dist/helpers/__tests__/user-provided-git.test.d.ts +0 -1
- package/dist/helpers/__tests__/user-provided-git.test.js +0 -119
- package/dist/helpers/__tests__/user-provided-git.test.js.map +0 -1
- package/dist/helpers/__tests__/utils.test.d.ts +0 -1
- package/dist/helpers/__tests__/utils.test.js +0 -429
- package/dist/helpers/__tests__/utils.test.js.map +0 -1
- package/dist/helpers/__tests__/validation.test.d.ts +0 -1
- package/dist/helpers/__tests__/validation.test.js +0 -25
- package/dist/helpers/__tests__/validation.test.js.map +0 -1
- package/dist/helpers/git/__tests__/format-git-sourcemaps-data.test.d.ts +0 -1
- package/dist/helpers/git/__tests__/format-git-sourcemaps-data.test.js +0 -103
- package/dist/helpers/git/__tests__/format-git-sourcemaps-data.test.js.map +0 -1
- package/dist/helpers/git/__tests__/format-git-span-data.test.d.ts +0 -1
- package/dist/helpers/git/__tests__/format-git-span-data.test.js +0 -121
- package/dist/helpers/git/__tests__/format-git-span-data.test.js.map +0 -1
- package/dist/helpers/git/__tests__/get-git-data.test.d.ts +0 -1
- package/dist/helpers/git/__tests__/get-git-data.test.js +0 -72
- package/dist/helpers/git/__tests__/get-git-data.test.js.map +0 -1
|
@@ -1,730 +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
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
35
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
|
-
};
|
|
37
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
const fs_1 = __importDefault(require("fs"));
|
|
39
|
-
const process_1 = __importDefault(require("process"));
|
|
40
|
-
const stream_1 = __importDefault(require("stream"));
|
|
41
|
-
const client_cloudwatch_logs_1 = require("@aws-sdk/client-cloudwatch-logs");
|
|
42
|
-
const client_lambda_1 = require("@aws-sdk/client-lambda");
|
|
43
|
-
const aws_sdk_client_mock_1 = require("aws-sdk-client-mock");
|
|
44
|
-
const constants_1 = require("../../../constants");
|
|
45
|
-
const fixtures_1 = require("../../../helpers/__tests__/fixtures");
|
|
46
|
-
const helpersFlareModule = __importStar(require("../../../helpers/flare"));
|
|
47
|
-
const fsModule = __importStar(require("../../../helpers/fs"));
|
|
48
|
-
const helpersPromptModule = __importStar(require("../../../helpers/prompt"));
|
|
49
|
-
const constants_2 = require("../constants");
|
|
50
|
-
const flare_1 = require("../flare");
|
|
51
|
-
const flareModule = __importStar(require("../flare"));
|
|
52
|
-
const commons_1 = require("../functions/commons");
|
|
53
|
-
const prompt_1 = require("../prompt");
|
|
54
|
-
const fixtures_2 = require("./fixtures");
|
|
55
|
-
// Constants
|
|
56
|
-
const MOCK_REGION = 'us-east-1';
|
|
57
|
-
const MOCK_REQUIRED_FLAGS = ['lambda', 'flare', '-f', 'func', '-r', MOCK_REGION, '-c', '123', '-e', 'test@test.com'];
|
|
58
|
-
const MOCK_LOG_GROUP = 'mockLogGroup';
|
|
59
|
-
const MOCK_TAGS = { Tags: {} };
|
|
60
|
-
const cloudWatchLogsClientMock = (0, aws_sdk_client_mock_1.mockClient)(client_cloudwatch_logs_1.CloudWatchLogsClient);
|
|
61
|
-
const lambdaClientMock = (0, aws_sdk_client_mock_1.mockClient)(client_lambda_1.LambdaClient);
|
|
62
|
-
// Commons mocks
|
|
63
|
-
jest.mock('../functions/commons', () => (Object.assign(Object.assign({}, jest.requireActual('../functions/commons')), { getAWSCredentials: jest.fn(), getLambdaFunctionConfig: jest.fn().mockImplementation(() => Promise.resolve(fixtures_2.MOCK_LAMBDA_CONFIG)) })));
|
|
64
|
-
// Prompt mocks
|
|
65
|
-
jest.mock('../prompt');
|
|
66
|
-
jest.spyOn(helpersPromptModule, 'requestFilePath').mockResolvedValue('');
|
|
67
|
-
jest.spyOn(helpersPromptModule, 'requestConfirmation').mockResolvedValue(true);
|
|
68
|
-
jest.spyOn(helpersFlareModule, 'getProjectFiles').mockResolvedValue(new Set());
|
|
69
|
-
// File system mocks
|
|
70
|
-
jest.spyOn(process_1.default, 'cwd').mockReturnValue(fixtures_1.MOCK_CWD);
|
|
71
|
-
jest.mock('fs');
|
|
72
|
-
fs_1.default.writeFileSync = jest.fn().mockImplementation(() => { });
|
|
73
|
-
fs_1.default.readFileSync = jest.fn().mockReturnValue(JSON.stringify(fixtures_2.MOCK_LAMBDA_CONFIG, undefined, 2));
|
|
74
|
-
fs_1.default.existsSync = jest.fn().mockReturnValue(true);
|
|
75
|
-
fs_1.default.createReadStream = jest.fn().mockImplementation(() =>
|
|
76
|
-
// Return a different stream every time, otherwise a `MaxListenersExceededWarning` is generated
|
|
77
|
-
// when appending this stream to the `FormData` under `flare_file`.
|
|
78
|
-
new stream_1.default.Readable({
|
|
79
|
-
read() {
|
|
80
|
-
this.push(JSON.stringify(fixtures_2.MOCK_LAMBDA_CONFIG, undefined, 2));
|
|
81
|
-
this.push(undefined);
|
|
82
|
-
},
|
|
83
|
-
}));
|
|
84
|
-
fs_1.default.readdirSync = jest.fn().mockReturnValue([]);
|
|
85
|
-
fs_1.default.statSync.mockImplementation((file_path) => ({
|
|
86
|
-
isDirectory: () => file_path === fixtures_1.MOCK_FLARE_FOLDER_PATH || file_path === fixtures_1.MOCK_CWD,
|
|
87
|
-
}));
|
|
88
|
-
// Date
|
|
89
|
-
jest.useFakeTimers({ now: new Date(Date.UTC(2023, 0)) });
|
|
90
|
-
jest.spyOn(flareModule, 'sleep').mockResolvedValue();
|
|
91
|
-
// Misc
|
|
92
|
-
jest.mock('util');
|
|
93
|
-
jest.mock('jszip');
|
|
94
|
-
jest.mock('../../../../package.json', () => ({
|
|
95
|
-
version: '1.0-mock-version',
|
|
96
|
-
}));
|
|
97
|
-
describe('lambda flare', () => {
|
|
98
|
-
beforeAll(() => {
|
|
99
|
-
(0, fixtures_2.mockResourceTags)(lambdaClientMock, MOCK_TAGS);
|
|
100
|
-
});
|
|
101
|
-
describe('prints correct headers', () => {
|
|
102
|
-
it('prints non-dry-run header', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
103
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
104
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
105
|
-
const code = yield cli.run(['lambda', 'flare'], context);
|
|
106
|
-
const output = context.stdout.toString();
|
|
107
|
-
expect(code).toBe(1);
|
|
108
|
-
expect(output).toMatchSnapshot();
|
|
109
|
-
}));
|
|
110
|
-
it('prints dry-run header', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
111
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
112
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
113
|
-
const code = yield cli.run(['lambda', 'flare', '-d'], context);
|
|
114
|
-
const output = context.stdout.toString();
|
|
115
|
-
expect(code).toBe(1);
|
|
116
|
-
expect(output).toMatchSnapshot();
|
|
117
|
-
}));
|
|
118
|
-
});
|
|
119
|
-
describe('validates required flags', () => {
|
|
120
|
-
beforeEach(() => {
|
|
121
|
-
process_1.default.env = { [constants_1.CI_API_KEY_ENV_VAR]: fixtures_1.MOCK_DATADOG_API_KEY };
|
|
122
|
-
});
|
|
123
|
-
it('prints error when no function specified', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
124
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
125
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
126
|
-
const code = yield cli.run(['lambda', 'flare', '-r', MOCK_REGION, '-c', '123', '-e', 'test@test.com'], context);
|
|
127
|
-
expect(code).toBe(1);
|
|
128
|
-
const output = context.stdout.toString();
|
|
129
|
-
expect(output).toMatchSnapshot();
|
|
130
|
-
}));
|
|
131
|
-
it('prints error when no region specified', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
132
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
133
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
134
|
-
const code = yield cli.run(['lambda', 'flare', '-f', 'func', '-c', '123', '-e', 'test@test.com'], context);
|
|
135
|
-
expect(code).toBe(1);
|
|
136
|
-
const output = context.stdout.toString();
|
|
137
|
-
expect(output).toMatchSnapshot();
|
|
138
|
-
}));
|
|
139
|
-
it('extracts region from function name when given a function ARN', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
140
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
141
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
142
|
-
const code = yield cli.run([
|
|
143
|
-
'lambda',
|
|
144
|
-
'flare',
|
|
145
|
-
'-f',
|
|
146
|
-
'arn:aws:lambda:us-east-1:123456789012:function:my-function',
|
|
147
|
-
'-c',
|
|
148
|
-
'123',
|
|
149
|
-
'-e',
|
|
150
|
-
'test@test.com',
|
|
151
|
-
], context);
|
|
152
|
-
expect(code).toBe(0);
|
|
153
|
-
const output = context.stdout.toString();
|
|
154
|
-
expect(output).toMatchSnapshot();
|
|
155
|
-
}));
|
|
156
|
-
it('uses region ENV variable when no region specified', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
157
|
-
process_1.default.env[constants_2.AWS_DEFAULT_REGION_ENV_VAR] = 'test-region';
|
|
158
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
159
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
160
|
-
const code = yield cli.run(['lambda', 'flare', '-f', 'func', '-c', '123', '-e', 'test@test.com'], context);
|
|
161
|
-
expect(code).toBe(0);
|
|
162
|
-
const output = context.stdout.toString();
|
|
163
|
-
expect(output).toMatchSnapshot();
|
|
164
|
-
}));
|
|
165
|
-
it('prints error when no API key in env variables', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
166
|
-
process_1.default.env = {};
|
|
167
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
168
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
169
|
-
const code = yield cli.run(['lambda', 'flare', '-f', 'func', '-r', MOCK_REGION, '-c', '123', '-e', 'test@test.com'], context);
|
|
170
|
-
expect(code).toBe(1);
|
|
171
|
-
const output = context.stdout.toString();
|
|
172
|
-
expect(output).toMatchSnapshot();
|
|
173
|
-
}));
|
|
174
|
-
it('uses API key ENV variable and runs as expected', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
175
|
-
process_1.default.env = {};
|
|
176
|
-
process_1.default.env[constants_1.CI_API_KEY_ENV_VAR] = fixtures_1.MOCK_DATADOG_API_KEY;
|
|
177
|
-
process_1.default.env[constants_1.API_KEY_ENV_VAR] = undefined;
|
|
178
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
179
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
180
|
-
let code = yield cli.run(['lambda', 'flare', '-f', 'func', '-r', MOCK_REGION, '-c', '123', '-e', 'test@test.com'], context);
|
|
181
|
-
expect(code).toBe(0);
|
|
182
|
-
let output = context.stdout.toString();
|
|
183
|
-
expect(output).toMatchSnapshot();
|
|
184
|
-
process_1.default.env[constants_1.CI_API_KEY_ENV_VAR] = undefined;
|
|
185
|
-
process_1.default.env[constants_1.API_KEY_ENV_VAR] = fixtures_1.MOCK_DATADOG_API_KEY;
|
|
186
|
-
code = yield cli.run(['lambda', 'flare', '-f', 'func', '-r', MOCK_REGION, '-c', '123', '-e', 'test@test.com'], context);
|
|
187
|
-
expect(code).toBe(0);
|
|
188
|
-
output = context.stdout.toString();
|
|
189
|
-
expect(output).toMatchSnapshot();
|
|
190
|
-
}));
|
|
191
|
-
it('prints error when no case ID specified', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
192
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
193
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
194
|
-
const code = yield cli.run(['lambda', 'flare', '-f', 'func', '-r', MOCK_REGION, '-e', 'test@test.com'], context);
|
|
195
|
-
expect(code).toBe(1);
|
|
196
|
-
const output = context.stdout.toString();
|
|
197
|
-
expect(output).toMatchSnapshot();
|
|
198
|
-
}));
|
|
199
|
-
it('prints error when no email specified', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
200
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
201
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
202
|
-
const code = yield cli.run(['lambda', 'flare', '-f', 'func', '-r', MOCK_REGION, '-c', '123'], context);
|
|
203
|
-
expect(code).toBe(1);
|
|
204
|
-
const output = context.stdout.toString();
|
|
205
|
-
expect(output).toMatchSnapshot();
|
|
206
|
-
}));
|
|
207
|
-
it('runs successfully with all required options specified', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
208
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
209
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
210
|
-
const code = yield cli.run(MOCK_REQUIRED_FLAGS, context);
|
|
211
|
-
expect(code).toBe(0);
|
|
212
|
-
const output = context.stdout.toString();
|
|
213
|
-
expect(output).toMatchSnapshot();
|
|
214
|
-
}));
|
|
215
|
-
it('prints error when start time is specified but end time is not', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
216
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
217
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
218
|
-
const code = yield cli.run([...MOCK_REQUIRED_FLAGS, '--start', '100'], context);
|
|
219
|
-
expect(code).toBe(1);
|
|
220
|
-
const output = context.stdout.toString();
|
|
221
|
-
expect(output).toMatchSnapshot();
|
|
222
|
-
}));
|
|
223
|
-
it('prints error when end time is specified but start time is not', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
224
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
225
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
226
|
-
const code = yield cli.run([...MOCK_REQUIRED_FLAGS, '--end', '100'], context);
|
|
227
|
-
expect(code).toBe(1);
|
|
228
|
-
const output = context.stdout.toString();
|
|
229
|
-
expect(output).toMatchSnapshot();
|
|
230
|
-
}));
|
|
231
|
-
it('prints error when start time is invalid', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
232
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
233
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
234
|
-
const code = yield cli.run([...MOCK_REQUIRED_FLAGS, '--start', '123abc', '--end', '200'], context);
|
|
235
|
-
expect(code).toBe(1);
|
|
236
|
-
const output = context.stdout.toString();
|
|
237
|
-
expect(output).toMatchSnapshot();
|
|
238
|
-
}));
|
|
239
|
-
it('prints error when end time is invalid', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
240
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
241
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
242
|
-
const code = yield cli.run([...MOCK_REQUIRED_FLAGS, '--start', '100', '--end', '123abc'], context);
|
|
243
|
-
expect(code).toBe(1);
|
|
244
|
-
const output = context.stdout.toString();
|
|
245
|
-
expect(output).toMatchSnapshot();
|
|
246
|
-
}));
|
|
247
|
-
it('prints error when start time is after end time', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
248
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
249
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
250
|
-
const code = yield cli.run([...MOCK_REQUIRED_FLAGS, '--start', '200', '--end', '100'], context);
|
|
251
|
-
expect(code).toBe(1);
|
|
252
|
-
const output = context.stdout.toString();
|
|
253
|
-
expect(output).toMatchSnapshot();
|
|
254
|
-
}));
|
|
255
|
-
it('runs successfully when start and end times are valid', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
256
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
257
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
258
|
-
const code = yield cli.run([...MOCK_REQUIRED_FLAGS, '--start', '100', '--end', '200'], context);
|
|
259
|
-
expect(code).toBe(0);
|
|
260
|
-
const output = context.stdout.toString();
|
|
261
|
-
expect(output).toMatchSnapshot();
|
|
262
|
-
}));
|
|
263
|
-
});
|
|
264
|
-
describe('getLogStreamNames', () => {
|
|
265
|
-
beforeEach(() => {
|
|
266
|
-
cloudWatchLogsClientMock.reset();
|
|
267
|
-
(0, fixtures_2.mockCloudWatchLogsClientCommands)(cloudWatchLogsClientMock);
|
|
268
|
-
});
|
|
269
|
-
it('returns the 3 latest log stream names sorted by last event time', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
270
|
-
const mockStreams = [
|
|
271
|
-
{ logStreamName: 'Stream3' },
|
|
272
|
-
{ logStreamName: 'Stream2' },
|
|
273
|
-
{ logStreamName: 'Stream1' },
|
|
274
|
-
];
|
|
275
|
-
(0, fixtures_2.mockCloudWatchLogStreams)(cloudWatchLogsClientMock, mockStreams);
|
|
276
|
-
const expectedLogStreams = ['Stream1', 'Stream2', 'Stream3'];
|
|
277
|
-
const logStreams = yield (0, flare_1.getLogStreamNames)(new client_cloudwatch_logs_1.CloudWatchLogsClient({}), MOCK_LOG_GROUP);
|
|
278
|
-
expect(logStreams).toEqual(expectedLogStreams);
|
|
279
|
-
}));
|
|
280
|
-
it('returns empty array when no log streams are found', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
281
|
-
(0, fixtures_2.mockCloudWatchLogStreams)(cloudWatchLogsClientMock, []);
|
|
282
|
-
const logStreams = yield (0, flare_1.getLogStreamNames)(new client_cloudwatch_logs_1.CloudWatchLogsClient({}), MOCK_LOG_GROUP);
|
|
283
|
-
expect(logStreams).toEqual([]);
|
|
284
|
-
}));
|
|
285
|
-
it('throws error when log streams cannot be retrieved', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
286
|
-
cloudWatchLogsClientMock.on(client_cloudwatch_logs_1.DescribeLogStreamsCommand).rejects('Cannot retrieve log streams');
|
|
287
|
-
yield expect((0, flare_1.getLogStreamNames)(cloudWatchLogsClientMock, MOCK_LOG_GROUP)).rejects.toThrow('Cannot retrieve log streams');
|
|
288
|
-
}));
|
|
289
|
-
it('returns log streams within the specified time range', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
290
|
-
const mockStreams = [
|
|
291
|
-
{ logStreamName: 'Stream1', firstEventTimestamp: 100, lastEventTimestamp: 200 },
|
|
292
|
-
{ logStreamName: 'Stream2', firstEventTimestamp: 200, lastEventTimestamp: 300 },
|
|
293
|
-
{ logStreamName: 'Stream3', firstEventTimestamp: 300, lastEventTimestamp: 400 },
|
|
294
|
-
{ logStreamName: 'Stream4', firstEventTimestamp: 400, lastEventTimestamp: 500 },
|
|
295
|
-
];
|
|
296
|
-
(0, fixtures_2.mockCloudWatchLogStreams)(cloudWatchLogsClientMock, mockStreams);
|
|
297
|
-
const expectedLogStreams = ['Stream2', 'Stream1'];
|
|
298
|
-
const logStreams = yield (0, flare_1.getLogStreamNames)(new client_cloudwatch_logs_1.CloudWatchLogsClient({}), MOCK_LOG_GROUP, 0, 250);
|
|
299
|
-
expect(logStreams).toEqual(expectedLogStreams);
|
|
300
|
-
}));
|
|
301
|
-
});
|
|
302
|
-
describe('getLogEvents', () => {
|
|
303
|
-
beforeEach(() => {
|
|
304
|
-
cloudWatchLogsClientMock.reset();
|
|
305
|
-
(0, fixtures_2.mockCloudWatchLogsClientCommands)(cloudWatchLogsClientMock);
|
|
306
|
-
});
|
|
307
|
-
const MOCK_LOG_STREAM = 'mockLogStream';
|
|
308
|
-
it('returns the log events for a log stream', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
309
|
-
(0, fixtures_2.mockCloudWatchLogEvents)(cloudWatchLogsClientMock, [
|
|
310
|
-
{ timestamp: 123, message: 'Log1' },
|
|
311
|
-
{ timestamp: 456, message: 'Log2' },
|
|
312
|
-
]);
|
|
313
|
-
const expectedEvents = [
|
|
314
|
-
{ timestamp: 123, message: 'Log1' },
|
|
315
|
-
{ timestamp: 456, message: 'Log2' },
|
|
316
|
-
];
|
|
317
|
-
const logEvents = yield (0, flare_1.getLogEvents)(cloudWatchLogsClientMock, MOCK_LOG_GROUP, MOCK_LOG_STREAM);
|
|
318
|
-
expect(logEvents).toEqual(expectedEvents);
|
|
319
|
-
}));
|
|
320
|
-
it('returns empty array when no log events are found', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
321
|
-
(0, fixtures_2.mockCloudWatchLogEvents)(cloudWatchLogsClientMock, []);
|
|
322
|
-
const logEvents = yield (0, flare_1.getLogEvents)(cloudWatchLogsClientMock, MOCK_LOG_GROUP, MOCK_LOG_STREAM);
|
|
323
|
-
expect(logEvents).toEqual([]);
|
|
324
|
-
}));
|
|
325
|
-
it('throws error when log events cannot be retrieved', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
326
|
-
cloudWatchLogsClientMock.on(client_cloudwatch_logs_1.GetLogEventsCommand).rejects('Cannot retrieve log events');
|
|
327
|
-
yield expect((0, flare_1.getLogEvents)(cloudWatchLogsClientMock, MOCK_LOG_GROUP, MOCK_LOG_STREAM)).rejects.toThrow('Cannot retrieve log events');
|
|
328
|
-
}));
|
|
329
|
-
it('sets start and end time when provided', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
330
|
-
const mockStartTime = 100;
|
|
331
|
-
const mockEndTime = 200;
|
|
332
|
-
const logEvents = [
|
|
333
|
-
{ timestamp: 125, message: 'Log1' },
|
|
334
|
-
{ timestamp: 150, message: 'Log2' },
|
|
335
|
-
{ timestamp: 175, message: 'Log3' },
|
|
336
|
-
];
|
|
337
|
-
const sendMock = jest.fn().mockResolvedValue({ events: logEvents });
|
|
338
|
-
cloudWatchLogsClientMock.send = sendMock;
|
|
339
|
-
const logEventsResult = yield (0, flare_1.getLogEvents)(cloudWatchLogsClientMock, MOCK_LOG_GROUP, MOCK_LOG_STREAM, mockStartTime, mockEndTime);
|
|
340
|
-
expect(sendMock).toHaveBeenCalledWith(expect.objectContaining({
|
|
341
|
-
input: expect.objectContaining({
|
|
342
|
-
logGroupName: MOCK_LOG_GROUP,
|
|
343
|
-
logStreamName: MOCK_LOG_STREAM,
|
|
344
|
-
limit: 1000,
|
|
345
|
-
startTime: mockStartTime,
|
|
346
|
-
endTime: mockEndTime,
|
|
347
|
-
}),
|
|
348
|
-
}));
|
|
349
|
-
expect(logEventsResult).toEqual(logEvents);
|
|
350
|
-
}));
|
|
351
|
-
});
|
|
352
|
-
describe('getAllLogs', () => {
|
|
353
|
-
const functionName = 'testFunction';
|
|
354
|
-
const mockStreamName = 'streamName';
|
|
355
|
-
it('returns a map of log streams and their events', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
356
|
-
const mockLogs = [
|
|
357
|
-
{ timestamp: 123, message: 'log message 1' },
|
|
358
|
-
{ timestamp: 124, message: 'log message 2' },
|
|
359
|
-
];
|
|
360
|
-
jest.spyOn(flareModule, 'getLogStreamNames').mockResolvedValue([mockStreamName]);
|
|
361
|
-
jest.spyOn(flareModule, 'getLogEvents').mockResolvedValue(mockLogs);
|
|
362
|
-
const result = yield (0, flare_1.getAllLogs)(MOCK_REGION, functionName);
|
|
363
|
-
expect(result.get(mockStreamName)).toEqual(mockLogs);
|
|
364
|
-
}));
|
|
365
|
-
it('throws an error when unable to get log streams', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
366
|
-
jest.spyOn(flareModule, 'getLogStreamNames').mockRejectedValueOnce(new Error('Error getting log streams'));
|
|
367
|
-
yield expect((0, flare_1.getAllLogs)(MOCK_REGION, functionName)).rejects.toMatchSnapshot();
|
|
368
|
-
}));
|
|
369
|
-
it('throws an error when unable to get log events', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
370
|
-
jest.spyOn(flareModule, 'getLogStreamNames').mockResolvedValueOnce([mockStreamName]);
|
|
371
|
-
jest.spyOn(flareModule, 'getLogEvents').mockRejectedValueOnce(new Error('Error getting log events'));
|
|
372
|
-
yield expect((0, flare_1.getAllLogs)(MOCK_REGION, functionName)).rejects.toMatchSnapshot();
|
|
373
|
-
}));
|
|
374
|
-
});
|
|
375
|
-
describe('gets CloudWatch Logs', () => {
|
|
376
|
-
process_1.default.env = { [constants_1.CI_API_KEY_ENV_VAR]: fixtures_1.MOCK_DATADOG_API_KEY };
|
|
377
|
-
const FLAGS_WITH_LOGS = [...MOCK_REQUIRED_FLAGS, '--with-logs'];
|
|
378
|
-
const mockLogStreamNames = ['Stream1', 'Stream2', 'Stream3'];
|
|
379
|
-
const mockLogEvents = [
|
|
380
|
-
{ timestamp: 123, message: 'Log1' },
|
|
381
|
-
{ timestamp: 456, message: 'Log2' },
|
|
382
|
-
];
|
|
383
|
-
beforeEach(() => {
|
|
384
|
-
jest.spyOn(flareModule, 'getLogStreamNames').mockResolvedValue(mockLogStreamNames);
|
|
385
|
-
jest.spyOn(flareModule, 'getLogEvents').mockResolvedValue(mockLogEvents);
|
|
386
|
-
});
|
|
387
|
-
it('gets logs, saves, and sends correctly when --with-logs is included', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
388
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
389
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
390
|
-
const code = yield cli.run(FLAGS_WITH_LOGS, context);
|
|
391
|
-
expect(code).toBe(0);
|
|
392
|
-
const output = context.stdout.toString();
|
|
393
|
-
expect(output).toMatchSnapshot();
|
|
394
|
-
}));
|
|
395
|
-
it('does not get logs when --with-logs is not included', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
396
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
397
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
398
|
-
const code = yield cli.run(MOCK_REQUIRED_FLAGS, context);
|
|
399
|
-
expect(code).toBe(0);
|
|
400
|
-
const output = context.stdout.toString();
|
|
401
|
-
expect(output).toMatchSnapshot();
|
|
402
|
-
}));
|
|
403
|
-
it('prints error when getLogStreamNames throws error', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
404
|
-
jest.spyOn(flareModule, 'getLogStreamNames').mockImplementation(() => {
|
|
405
|
-
throw new Error('MOCK ERROR: Unable to get log stream names');
|
|
406
|
-
});
|
|
407
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
408
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
409
|
-
const code = yield cli.run(FLAGS_WITH_LOGS, context);
|
|
410
|
-
expect(code).toBe(1);
|
|
411
|
-
const output = context.stdout.toString();
|
|
412
|
-
expect(output).toMatchSnapshot();
|
|
413
|
-
}));
|
|
414
|
-
it('warns and skips getting logs when getLogStreamNames returns []', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
415
|
-
jest.spyOn(flareModule, 'getLogStreamNames').mockResolvedValue([]);
|
|
416
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
417
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
418
|
-
const code = yield cli.run(FLAGS_WITH_LOGS, context);
|
|
419
|
-
expect(code).toBe(0);
|
|
420
|
-
const output = context.stdout.toString();
|
|
421
|
-
expect(output).toMatchSnapshot();
|
|
422
|
-
}));
|
|
423
|
-
it('prints error when getLogEvents throws error', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
424
|
-
jest.spyOn(flareModule, 'getLogEvents').mockImplementation(() => {
|
|
425
|
-
throw new Error('MOCK ERROR: Unable to get log events');
|
|
426
|
-
});
|
|
427
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
428
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
429
|
-
const code = yield cli.run(FLAGS_WITH_LOGS, context);
|
|
430
|
-
expect(code).toBe(1);
|
|
431
|
-
const output = context.stdout.toString();
|
|
432
|
-
expect(output).toMatchSnapshot();
|
|
433
|
-
}));
|
|
434
|
-
it('warns and skips log when getLogEvents returns []', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
435
|
-
jest.spyOn(flareModule, 'getLogEvents').mockResolvedValue([]);
|
|
436
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
437
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
438
|
-
const code = yield cli.run(FLAGS_WITH_LOGS, context);
|
|
439
|
-
expect(code).toBe(0);
|
|
440
|
-
const output = context.stdout.toString();
|
|
441
|
-
expect(output).toMatchSnapshot();
|
|
442
|
-
}));
|
|
443
|
-
});
|
|
444
|
-
describe('getTags', () => {
|
|
445
|
-
const MOCK_ARN = 'arn:aws:lambda:us-east-1:123456789012:function:my-function';
|
|
446
|
-
afterAll(() => {
|
|
447
|
-
(0, fixtures_2.mockResourceTags)(lambdaClientMock, MOCK_TAGS);
|
|
448
|
-
});
|
|
449
|
-
it('should return the tags when they exist', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
450
|
-
const mockTags = { Tags: { Key1: 'Value1', Key2: 'Value2' } };
|
|
451
|
-
(0, fixtures_2.mockResourceTags)(lambdaClientMock, mockTags);
|
|
452
|
-
const tags = yield (0, flare_1.getTags)(lambdaClientMock, MOCK_REGION, MOCK_ARN);
|
|
453
|
-
expect(tags).toMatchSnapshot();
|
|
454
|
-
}));
|
|
455
|
-
it('should return an empty object when there are no tags', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
456
|
-
const mockTags = { Tags: {} };
|
|
457
|
-
(0, fixtures_2.mockResourceTags)(lambdaClientMock, mockTags);
|
|
458
|
-
const tags = yield (0, flare_1.getTags)(lambdaClientMock, MOCK_REGION, MOCK_ARN);
|
|
459
|
-
expect(tags).toEqual({});
|
|
460
|
-
}));
|
|
461
|
-
it('should throw an error when the command fails', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
462
|
-
const errorMessage = 'Unable to get resource tags: Test Error';
|
|
463
|
-
lambdaClientMock.on(client_lambda_1.ListTagsCommand).rejects(new Error('Test Error'));
|
|
464
|
-
yield expect((0, flare_1.getTags)(lambdaClientMock, MOCK_REGION, MOCK_ARN)).rejects.toThrow(errorMessage);
|
|
465
|
-
}));
|
|
466
|
-
});
|
|
467
|
-
describe('convertToCSV', () => {
|
|
468
|
-
it('returns a CSV string from an array of log events', () => {
|
|
469
|
-
const mockLogEvents = [
|
|
470
|
-
{ timestamp: 123, message: 'Log 1' },
|
|
471
|
-
{ timestamp: 456, message: 'Log 2' },
|
|
472
|
-
];
|
|
473
|
-
expect((0, flare_1.convertToCSV)(mockLogEvents)).toMatchSnapshot();
|
|
474
|
-
});
|
|
475
|
-
it('handles missing timestamp and message in log events', () => {
|
|
476
|
-
const mockLogEvents = [
|
|
477
|
-
{ timestamp: undefined, message: 'Log 1' },
|
|
478
|
-
{ timestamp: 456, message: undefined },
|
|
479
|
-
];
|
|
480
|
-
expect((0, flare_1.convertToCSV)(mockLogEvents)).toMatchSnapshot();
|
|
481
|
-
});
|
|
482
|
-
it('returns a CSV string with only headers when given an empty array', () => {
|
|
483
|
-
const mockLogEvents = [];
|
|
484
|
-
expect((0, flare_1.convertToCSV)(mockLogEvents)).toMatchSnapshot();
|
|
485
|
-
});
|
|
486
|
-
});
|
|
487
|
-
describe('getFramework', () => {
|
|
488
|
-
it('returns Serverless Framework when serverless.yml exists', () => {
|
|
489
|
-
;
|
|
490
|
-
fs_1.default.readdirSync.mockReturnValueOnce(['serverless.yml', 'test.js']);
|
|
491
|
-
expect((0, flare_1.getFramework)()).toBe(constants_2.DeploymentFrameworks.ServerlessFramework);
|
|
492
|
-
});
|
|
493
|
-
it('returns AWS CDK when cdk.json exists', () => {
|
|
494
|
-
;
|
|
495
|
-
fs_1.default.readdirSync.mockReturnValueOnce(['abc.md', 'Dockerfile', 'cdk.json']);
|
|
496
|
-
expect((0, flare_1.getFramework)()).toBe(constants_2.DeploymentFrameworks.AwsCdk);
|
|
497
|
-
});
|
|
498
|
-
it('returns AWS CloudFormation when template.yaml exists', () => {
|
|
499
|
-
;
|
|
500
|
-
fs_1.default.readdirSync.mockReturnValueOnce(['abc.md', 'template.yaml', 'Dockerfile']);
|
|
501
|
-
expect((0, flare_1.getFramework)()).toBe(constants_2.DeploymentFrameworks.AwsCloudFormation);
|
|
502
|
-
});
|
|
503
|
-
it('returns Unknown when no framework files exist', () => {
|
|
504
|
-
;
|
|
505
|
-
fs_1.default.readdirSync.mockReturnValueOnce(['abc.md', 'Dockerfile', 'test.js', 'README.md']);
|
|
506
|
-
expect((0, flare_1.getFramework)()).toBe(constants_2.DeploymentFrameworks.Unknown);
|
|
507
|
-
});
|
|
508
|
-
it('returns multiple frameworks when multiple are found', () => {
|
|
509
|
-
;
|
|
510
|
-
fs_1.default.readdirSync.mockReturnValueOnce(['serverless.yml', 'cdk.json', 'Dockerfile']);
|
|
511
|
-
expect((0, flare_1.getFramework)()).toBe(`${constants_2.DeploymentFrameworks.ServerlessFramework}, ${constants_2.DeploymentFrameworks.AwsCdk}`);
|
|
512
|
-
});
|
|
513
|
-
});
|
|
514
|
-
describe('generateInsightsFile', () => {
|
|
515
|
-
const insightsFilePath = 'mock/INSIGHTS.md';
|
|
516
|
-
const writeFileSpy = jest.spyOn(fsModule, 'writeFile');
|
|
517
|
-
it('should call writeFile with correct content when isDryRun is false', () => {
|
|
518
|
-
(0, flare_1.generateInsightsFile)(insightsFilePath, false, (0, commons_1.maskConfig)(fixtures_2.MOCK_LAMBDA_CONFIG));
|
|
519
|
-
expect(writeFileSpy).toHaveBeenCalledTimes(1);
|
|
520
|
-
const receivedContent = writeFileSpy.mock.calls[0][1];
|
|
521
|
-
expect(receivedContent).toMatchSnapshot();
|
|
522
|
-
});
|
|
523
|
-
it('should call writeFile with correct content when isDryRun is true', () => {
|
|
524
|
-
(0, flare_1.generateInsightsFile)(insightsFilePath, true, (0, commons_1.maskConfig)(fixtures_2.MOCK_LAMBDA_CONFIG));
|
|
525
|
-
expect(writeFileSpy).toHaveBeenCalledTimes(1);
|
|
526
|
-
const receivedContent = writeFileSpy.mock.calls[0][1];
|
|
527
|
-
expect(receivedContent).toMatchSnapshot();
|
|
528
|
-
});
|
|
529
|
-
it('prints a warning when generateInsightsFile() errors', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
530
|
-
jest.spyOn(flareModule, 'generateInsightsFile').mockImplementationOnce(() => {
|
|
531
|
-
throw new Error('Some error');
|
|
532
|
-
});
|
|
533
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
534
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
535
|
-
const code = yield cli.run(MOCK_REQUIRED_FLAGS, context);
|
|
536
|
-
const output = context.stdout.toString();
|
|
537
|
-
expect(code).toBe(0);
|
|
538
|
-
expect(output).toMatchSnapshot();
|
|
539
|
-
}));
|
|
540
|
-
});
|
|
541
|
-
describe('AWS Lambda configuration', () => {
|
|
542
|
-
it('stops and prints error when getLambdaFunctionConfig fails', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
543
|
-
;
|
|
544
|
-
commons_1.getLambdaFunctionConfig.mockImplementation(() => {
|
|
545
|
-
throw new Error('MOCK ERROR: Some API error');
|
|
546
|
-
});
|
|
547
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
548
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
549
|
-
const code = yield cli.run(MOCK_REQUIRED_FLAGS, context);
|
|
550
|
-
expect(code).toBe(1);
|
|
551
|
-
const output = context.stdout.toString();
|
|
552
|
-
expect(output).toMatchSnapshot();
|
|
553
|
-
}));
|
|
554
|
-
it('prints config when running as a dry run', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
555
|
-
;
|
|
556
|
-
commons_1.getLambdaFunctionConfig.mockImplementation(() => Promise.resolve(fixtures_2.MOCK_LAMBDA_CONFIG));
|
|
557
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
558
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
559
|
-
const code = yield cli.run([...MOCK_REQUIRED_FLAGS, '-d'], context);
|
|
560
|
-
expect(code).toBe(0);
|
|
561
|
-
const output = context.stdout.toString();
|
|
562
|
-
expect(output).toMatchSnapshot();
|
|
563
|
-
}));
|
|
564
|
-
});
|
|
565
|
-
describe('AWS credentials', () => {
|
|
566
|
-
it('continues when getAWSCredentials() returns valid credentials', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
567
|
-
;
|
|
568
|
-
commons_1.getAWSCredentials.mockResolvedValue(fixtures_2.mockAwsCredentials);
|
|
569
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
570
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
571
|
-
const code = yield cli.run(MOCK_REQUIRED_FLAGS, context);
|
|
572
|
-
expect(code).toBe(0);
|
|
573
|
-
const output = context.stdout.toString();
|
|
574
|
-
expect(output).toMatchSnapshot();
|
|
575
|
-
expect(prompt_1.requestAWSCredentials).not.toHaveBeenCalled();
|
|
576
|
-
}));
|
|
577
|
-
it('requests AWS credentials when none are found by getAWSCredentials()', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
578
|
-
;
|
|
579
|
-
commons_1.getAWSCredentials.mockResolvedValue(undefined);
|
|
580
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
581
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
582
|
-
const code = yield cli.run(MOCK_REQUIRED_FLAGS, context);
|
|
583
|
-
expect(code).toBe(0);
|
|
584
|
-
const output = context.stdout.toString();
|
|
585
|
-
expect(output).toMatchSnapshot();
|
|
586
|
-
expect(prompt_1.requestAWSCredentials).toHaveBeenCalled();
|
|
587
|
-
}));
|
|
588
|
-
it('stops and prints error when getAWSCredentials() fails', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
589
|
-
;
|
|
590
|
-
commons_1.getAWSCredentials.mockImplementation(() => {
|
|
591
|
-
throw new Error('MOCK ERROR: Error getting AWS credentials');
|
|
592
|
-
});
|
|
593
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
594
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
595
|
-
const code = yield cli.run(MOCK_REQUIRED_FLAGS, context);
|
|
596
|
-
expect(code).toBe(1);
|
|
597
|
-
const output = context.stdout.toString();
|
|
598
|
-
expect(output).toMatchSnapshot();
|
|
599
|
-
}));
|
|
600
|
-
it('stops and prints error when requestAWSCredentials() fails', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
601
|
-
;
|
|
602
|
-
commons_1.getAWSCredentials.mockResolvedValue(undefined);
|
|
603
|
-
prompt_1.requestAWSCredentials.mockImplementation(() => {
|
|
604
|
-
throw new Error('MOCK ERROR: Error requesting AWS credentials');
|
|
605
|
-
});
|
|
606
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
607
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
608
|
-
const code = yield cli.run(MOCK_REQUIRED_FLAGS, context);
|
|
609
|
-
expect(prompt_1.requestAWSCredentials).toHaveBeenCalled();
|
|
610
|
-
expect(code).toBe(1);
|
|
611
|
-
const output = context.stdout.toString();
|
|
612
|
-
expect(output).toMatchSnapshot();
|
|
613
|
-
}));
|
|
614
|
-
});
|
|
615
|
-
describe('prompts for confirmation before sending', () => {
|
|
616
|
-
beforeEach(() => {
|
|
617
|
-
;
|
|
618
|
-
commons_1.getAWSCredentials.mockResolvedValue(fixtures_2.mockAwsCredentials);
|
|
619
|
-
});
|
|
620
|
-
it('sends when user answers prompt with yes', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
621
|
-
// The first prompt is for additional files, the second is for confirmation before sending
|
|
622
|
-
jest.spyOn(helpersPromptModule, 'requestConfirmation').mockResolvedValueOnce(true).mockResolvedValueOnce(true);
|
|
623
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
624
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
625
|
-
const code = yield cli.run(MOCK_REQUIRED_FLAGS, context);
|
|
626
|
-
expect(code).toBe(0);
|
|
627
|
-
const output = context.stdout.toString();
|
|
628
|
-
expect(output).toMatchSnapshot();
|
|
629
|
-
expect(output).toContain('✅ Successfully sent flare file to Datadog Support!');
|
|
630
|
-
}));
|
|
631
|
-
it('does not send when user answers prompt with no', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
632
|
-
// The first prompt is for additional files, the second is for confirmation before sending
|
|
633
|
-
jest.spyOn(helpersPromptModule, 'requestConfirmation').mockResolvedValueOnce(true).mockResolvedValueOnce(false);
|
|
634
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
635
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
636
|
-
const code = yield cli.run(MOCK_REQUIRED_FLAGS, context);
|
|
637
|
-
expect(code).toBe(0);
|
|
638
|
-
const output = context.stdout.toString();
|
|
639
|
-
expect(output).toMatchSnapshot();
|
|
640
|
-
expect(output).toContain('🚫 The flare files were not sent based on your selection.');
|
|
641
|
-
}));
|
|
642
|
-
});
|
|
643
|
-
describe('prompts for additional files', () => {
|
|
644
|
-
beforeEach(() => {
|
|
645
|
-
;
|
|
646
|
-
commons_1.getAWSCredentials.mockResolvedValue(fixtures_2.mockAwsCredentials);
|
|
647
|
-
});
|
|
648
|
-
it('requests additional files when user answers yes', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
649
|
-
// The first prompt is for additional files, the second is for confirmation before sending
|
|
650
|
-
jest.spyOn(helpersPromptModule, 'requestConfirmation').mockResolvedValueOnce(true).mockResolvedValueOnce(true);
|
|
651
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
652
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
653
|
-
const code = yield cli.run(MOCK_REQUIRED_FLAGS, context);
|
|
654
|
-
expect(code).toBe(0);
|
|
655
|
-
const output = context.stdout.toString();
|
|
656
|
-
expect(output).toMatchSnapshot();
|
|
657
|
-
expect(output).toContain('[!] No additional files specified.');
|
|
658
|
-
}));
|
|
659
|
-
it('does not request additional files when user answers no', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
660
|
-
// The first prompt is for additional files, the second is for confirmation before sending
|
|
661
|
-
jest.spyOn(helpersPromptModule, 'requestConfirmation').mockResolvedValueOnce(false).mockResolvedValueOnce(true);
|
|
662
|
-
const cli = (0, fixtures_2.makeCli)();
|
|
663
|
-
const context = (0, fixtures_1.createMockContext)();
|
|
664
|
-
const code = yield cli.run(MOCK_REQUIRED_FLAGS, context);
|
|
665
|
-
expect(code).toBe(0);
|
|
666
|
-
const output = context.stdout.toString();
|
|
667
|
-
expect(output).toMatchSnapshot();
|
|
668
|
-
expect(output).not.toContain('Added 0 custom file(s)');
|
|
669
|
-
}));
|
|
670
|
-
});
|
|
671
|
-
describe('getUniqueFilesNames', () => {
|
|
672
|
-
it('should return file names when all are unique', () => {
|
|
673
|
-
const mockFilePaths = new Set(['src/serverless.yml', 'src/package.json']);
|
|
674
|
-
const expectedFiles = new Map([
|
|
675
|
-
['src/serverless.yml', 'serverless.yml'],
|
|
676
|
-
['src/package.json', 'package.json'],
|
|
677
|
-
]);
|
|
678
|
-
const result = (0, flare_1.getUniqueFileNames)(mockFilePaths);
|
|
679
|
-
expect(result).toEqual(expectedFiles);
|
|
680
|
-
});
|
|
681
|
-
it('returns unique file names when there are duplicates', () => {
|
|
682
|
-
const mockFilePaths = new Set([
|
|
683
|
-
'src/func1/serverless.yml',
|
|
684
|
-
'src/func2/serverless.yml',
|
|
685
|
-
'src/func1/package.json',
|
|
686
|
-
'src/func2/package.json',
|
|
687
|
-
'src/Dockerfile',
|
|
688
|
-
'src/README.md',
|
|
689
|
-
]);
|
|
690
|
-
const expectedFiles = new Map([
|
|
691
|
-
['src/func1/serverless.yml', 'src-func1-serverless.yml'],
|
|
692
|
-
['src/func2/serverless.yml', 'src-func2-serverless.yml'],
|
|
693
|
-
['src/func1/package.json', 'src-func1-package.json'],
|
|
694
|
-
['src/func2/package.json', 'src-func2-package.json'],
|
|
695
|
-
['src/Dockerfile', 'Dockerfile'],
|
|
696
|
-
['src/README.md', 'README.md'],
|
|
697
|
-
]);
|
|
698
|
-
const result = (0, flare_1.getUniqueFileNames)(mockFilePaths);
|
|
699
|
-
expect(result).toEqual(expectedFiles);
|
|
700
|
-
});
|
|
701
|
-
it('returns unique file names when there are duplicates with different prefixes', () => {
|
|
702
|
-
const mockFilePaths = new Set([
|
|
703
|
-
'project1/src/func1/serverless.yml',
|
|
704
|
-
'project1/src/func2/serverless.yml',
|
|
705
|
-
'project2/src/func1/serverless.yml',
|
|
706
|
-
'project2/src/func2/serverless.yml',
|
|
707
|
-
'project2/src/func3/serverless.yml',
|
|
708
|
-
'project3/src/cool_function/serverless.yml',
|
|
709
|
-
'src/Dockerfile',
|
|
710
|
-
'src/README.md',
|
|
711
|
-
]);
|
|
712
|
-
const expectedFiles = new Map([
|
|
713
|
-
['project1/src/func1/serverless.yml', 'project1-src-func1-serverless.yml'],
|
|
714
|
-
['project1/src/func2/serverless.yml', 'project1-src-func2-serverless.yml'],
|
|
715
|
-
['project2/src/func1/serverless.yml', 'project2-src-func1-serverless.yml'],
|
|
716
|
-
['project2/src/func2/serverless.yml', 'project2-src-func2-serverless.yml'],
|
|
717
|
-
['project2/src/func3/serverless.yml', 'project2-src-func3-serverless.yml'],
|
|
718
|
-
['project3/src/cool_function/serverless.yml', 'project3-src-cool_function-serverless.yml'],
|
|
719
|
-
['src/Dockerfile', 'Dockerfile'],
|
|
720
|
-
['src/README.md', 'README.md'],
|
|
721
|
-
]);
|
|
722
|
-
const result = (0, flare_1.getUniqueFileNames)(mockFilePaths);
|
|
723
|
-
expect(result).toEqual(expectedFiles);
|
|
724
|
-
});
|
|
725
|
-
});
|
|
726
|
-
test('summarizeConfig', () => {
|
|
727
|
-
expect((0, flare_1.summarizeConfig)(fixtures_2.MOCK_LAMBDA_CONFIG)).toMatchSnapshot();
|
|
728
|
-
});
|
|
729
|
-
});
|
|
730
|
-
//# sourceMappingURL=flare.test.js.map
|