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();