From 2ccedc44ba3ccd4c7143808263b9cfdfbf4d417d Mon Sep 17 00:00:00 2001 From: Gonzalo Garcia Jaubert Date: Tue, 28 Dec 2021 10:12:47 +0000 Subject: [PATCH] feat(core): Rockets 2.0. Fail if env variable is not set on Azure integration tests (#1006) --- .../integration/helper/app-helper.ts | 12 +++++++++++- .../azure/deployment/deployment.integration.ts | 4 ++-- .../provider-specific/azure/nuke/nuke.integration.ts | 4 ++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/framework-integration-tests/integration/helper/app-helper.ts b/packages/framework-integration-tests/integration/helper/app-helper.ts index 354981920..1b7f23546 100644 --- a/packages/framework-integration-tests/integration/helper/app-helper.ts +++ b/packages/framework-integration-tests/integration/helper/app-helper.ts @@ -12,7 +12,7 @@ export function applicationName(): string { export async function getProviderTestHelper(): Promise { const provider = process.env.TESTED_PROVIDER - const environmentName = process.env.BOOSTER_ENV ?? 'azure' + const environmentName = checkAndGetCurrentEnv() const providerHelpers: Record Promise> = { AWS: () => AWSTestHelper.build(applicationName()), AZURE: () => AzureTestHelper.build(applicationName(), environmentName), @@ -38,3 +38,13 @@ export async function setEnv(): Promise { console.log('setting BOOSTER_APP_SUFFIX=' + process.env.BOOSTER_APP_SUFFIX) } } + +export function checkAndGetCurrentEnv(): string { + const env = process.env.BOOSTER_ENV + if (!env || env.trim().length == 0) { + throw new Error( + 'Booster environment is missing. You need to provide an environment to configure your Booster project' + ) + } + return env +} diff --git a/packages/framework-integration-tests/integration/provider-specific/azure/deployment/deployment.integration.ts b/packages/framework-integration-tests/integration/provider-specific/azure/deployment/deployment.integration.ts index fa86f432a..fe0911672 100644 --- a/packages/framework-integration-tests/integration/provider-specific/azure/deployment/deployment.integration.ts +++ b/packages/framework-integration-tests/integration/provider-specific/azure/deployment/deployment.integration.ts @@ -1,6 +1,6 @@ import { AzureTestHelper } from '@boostercloud/framework-provider-azure-infrastructure' import { expect } from '../../../helper/expect' -import { applicationName } from '../../../helper/app-helper' +import { applicationName, checkAndGetCurrentEnv } from '../../../helper/app-helper' describe('After deployment', () => { describe('the ARM template', () => { @@ -8,7 +8,7 @@ describe('After deployment', () => { // The project must have been deployed by the cliHelper hook in setup.ts // that scripts uses the cli to do the deployment, so we just check here // that the resource group exists - const environmentName = process.env.BOOSTER_ENV ?? 'azure' + const environmentName = checkAndGetCurrentEnv() await expect(AzureTestHelper.checkResourceGroup(applicationName(), environmentName)).to.be.eventually.fulfilled }) }) diff --git a/packages/framework-integration-tests/integration/provider-specific/azure/nuke/nuke.integration.ts b/packages/framework-integration-tests/integration/provider-specific/azure/nuke/nuke.integration.ts index b4381592e..ff615a057 100644 --- a/packages/framework-integration-tests/integration/provider-specific/azure/nuke/nuke.integration.ts +++ b/packages/framework-integration-tests/integration/provider-specific/azure/nuke/nuke.integration.ts @@ -1,11 +1,11 @@ import { AzureTestHelper } from '@boostercloud/framework-provider-azure-infrastructure' -import { applicationName } from '../../../helper/app-helper' +import { applicationName, checkAndGetCurrentEnv } from '../../../helper/app-helper' import { expect } from '../../../helper/expect' describe('After nuke', () => { describe('the resource group', () => { it('is deleted successfully', async () => { - const environmentName = process.env.BOOSTER_ENV ?? 'azure' + const environmentName = checkAndGetCurrentEnv() await expect( AzureTestHelper.checkResourceGroup(applicationName(), environmentName) ).to.be.eventually.rejectedWith('ResourceGroupNotFound')