Skip to content

Commit

Permalink
feat(core): Rockets 2.0. Fail if env variable is not set on Azure int…
Browse files Browse the repository at this point in the history
…egration tests (#1006)
  • Loading branch information
gonzalogarciajaubert authored Dec 28, 2021
1 parent 77a481e commit 2ccedc4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function applicationName(): string {

export async function getProviderTestHelper(): Promise<ProviderTestHelper> {
const provider = process.env.TESTED_PROVIDER
const environmentName = process.env.BOOSTER_ENV ?? 'azure'
const environmentName = checkAndGetCurrentEnv()
const providerHelpers: Record<string, () => Promise<ProviderTestHelper>> = {
AWS: () => AWSTestHelper.build(applicationName()),
AZURE: () => AzureTestHelper.build(applicationName(), environmentName),
Expand All @@ -38,3 +38,13 @@ export async function setEnv(): Promise<void> {
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
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
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', () => {
it('has been created successfully', async () => {
// 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
})
})
Expand Down
Original file line number Diff line number Diff line change
@@ -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')
Expand Down

0 comments on commit 2ccedc4

Please sign in to comment.