Skip to content

Commit

Permalink
Fix env.spec.ts test (#137)
Browse files Browse the repository at this point in the history
* Fix env.spec.ts test

* add `exclude` back

---------

Co-authored-by: jordan gonzález <30836115+duncanista@users.noreply.github.com>
  • Loading branch information
lym953 and duncanista authored Dec 10, 2024
1 parent 59ae2d4 commit bf02c45
Showing 1 changed file with 46 additions and 40 deletions.
86 changes: 46 additions & 40 deletions serverless/test/env.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("getConfig", () => {

it("gets default configuration when no parameters are specified", () => {
const config = getConfigFromCfnParams({});
expect(config).toEqual(defaultConfiguration);
expect(config).toEqual(expect.objectContaining(defaultConfiguration));
});

it("gets a mixed a configuration when some values are present", () => {
Expand All @@ -31,18 +31,20 @@ describe("getConfig", () => {
enableXrayTracing: false,
};
const config = getConfigFromCfnParams(params);
expect(config).toEqual({
addLayers: true,
addExtension: false,
exclude: [],
flushMetricsToLogs: true,
site: "my-site",
enableXrayTracing: false,
enableDDTracing: true,
enableDDLogs: true,
enableEnhancedMetrics: true,
captureLambdaPayload: false,
});
expect(config).toEqual(
expect.objectContaining({
addLayers: true,
addExtension: false,
exclude: [],
flushMetricsToLogs: true,
site: "my-site",
enableXrayTracing: false,
enableDDTracing: true,
enableDDLogs: true,
enableEnhancedMetrics: true,
captureLambdaPayload: false,
}),
);
});

describe("with env vars set", () => {
Expand All @@ -62,20 +64,22 @@ describe("getConfig", () => {
"arn:aws:secretsmanager:my-region-1:123456789012:secret:DdApiKeySecret-abcd1234";
process.env["DD_FLUSH_TO_LOG"] = "false";
const config = getConfigFromEnvVars();
expect(config).toEqual({
addLayers: true,
addExtension: false,
exclude: [],
flushMetricsToLogs: false,
logLevel: undefined,
site: "datadoghq.com",
enableXrayTracing: false,
enableDDTracing: true,
enableDDLogs: true,
enableEnhancedMetrics: true,
captureLambdaPayload: false,
apiKeySecretArn: "arn:aws:secretsmanager:my-region-1:123456789012:secret:DdApiKeySecret-abcd1234",
});
expect(config).toEqual(
expect.objectContaining({
addLayers: true,
addExtension: false,
exclude: [],
flushMetricsToLogs: false,
logLevel: undefined,
site: "datadoghq.com",
enableXrayTracing: false,
enableDDTracing: true,
enableDDLogs: true,
enableEnhancedMetrics: true,
captureLambdaPayload: false,
apiKeySecretArn: "arn:aws:secretsmanager:my-region-1:123456789012:secret:DdApiKeySecret-abcd1234",
}),
);
});

it("gets a mixed a configuration when some values are present", () => {
Expand All @@ -91,19 +95,21 @@ describe("getConfig", () => {
captureLambdaPayload: false,
};
const config = getConfigFromCfnParams(params);
expect(config).toEqual({
addLayers: true,
addExtension: false,
exclude: [],
flushMetricsToLogs: false,
site: "my-site",
enableXrayTracing: false,
enableDDTracing: true,
enableDDLogs: true,
enableEnhancedMetrics: true,
captureLambdaPayload: false,
apiKeySecretArn: "arn:aws:secretsmanager:my-region-1:123456789012:secret:DdApiKeySecret-abcd1234",
});
expect(config).toEqual(
expect.objectContaining({
addLayers: true,
addExtension: false,
exclude: [],
flushMetricsToLogs: false,
site: "my-site",
enableXrayTracing: false,
enableDDTracing: true,
enableDDLogs: true,
enableEnhancedMetrics: true,
captureLambdaPayload: false,
apiKeySecretArn: "arn:aws:secretsmanager:my-region-1:123456789012:secret:DdApiKeySecret-abcd1234",
}),
);
});
});
});
Expand Down

0 comments on commit bf02c45

Please sign in to comment.