From 4d41432af1e7d17065b6ce2c9612da276afcb7dd Mon Sep 17 00:00:00 2001 From: Joy Liu Date: Sun, 22 Oct 2023 12:09:28 -0400 Subject: [PATCH] the power of eunsoo shin --- cdk/kittyhawk/test/deployment.test.ts | 14 ++++++++++++++ cdk/kittyhawk/test/utils.ts | 10 +++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/cdk/kittyhawk/test/deployment.test.ts b/cdk/kittyhawk/test/deployment.test.ts index eca1c37e..685c844f 100644 --- a/cdk/kittyhawk/test/deployment.test.ts +++ b/cdk/kittyhawk/test/deployment.test.ts @@ -37,3 +37,17 @@ test("Deployment -- Default", () => chartTest(buildDeploymentDefault)); test("Container -- Default", () => chartTest(buildContainerDefault)); test("Container -- No Git Sha", () => failingTestNoGitSha(buildContainerDefault)); + +export const failingContainerTestNoGitSha = (_: (scope: Construct) => void) => { + const { GIT_SHA, ...env } = process.env; + + process.env = { + ...env, + RELEASE_NAME: "RELEASE_NAME", + AWS_ACCOUNT_ID: "TEST_AWS_ACCOUNT_ID", + }; + + expect(() => { + buildContainerDefault; + }).toThrowError("process.exit: 1"); +}; diff --git a/cdk/kittyhawk/test/utils.ts b/cdk/kittyhawk/test/utils.ts index fe85baa6..b3ca98d5 100644 --- a/cdk/kittyhawk/test/utils.ts +++ b/cdk/kittyhawk/test/utils.ts @@ -46,9 +46,13 @@ const mockConsoleError = jest.spyOn(console, "error").mockImplementation(() => { }); export const failingTestNoGitSha = (_: (scope: Construct) => void) => { - process.env.RELEASE_NAME = "RELEASE_NAME"; - process.env.GIT_SHA = ""; - process.env.AWS_ACCOUNT_ID = "TEST_AWS_ACCOUNT_ID"; + const { GIT_SHA, ...env } = process.env; + + process.env = { + ...env, + RELEASE_NAME: "RELEASE_NAME", + AWS_ACCOUNT_ID: "TEST_AWS_ACCOUNT_ID", + }; expect(() => { const app = Testing.app();