Skip to content

Commit d541221

Browse files
committed
E6-3: Re-enable use of existing stacks for integration tests, don't tear them down
1 parent 0fa2262 commit d541221

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

__tests__/integration/api-integration.test.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,22 @@ const {beforeAll, afterAll, test, expect} = require("@jest/globals"),
66

77
const cloudFormation = new AWS.CloudFormation()
88

9+
const isUsingEphemeralStack = !process.env.hasOwnProperty('STACK_NAME')
910
let stackName
1011
let apiEndpoint
1112

1213
beforeAll(async () => {
13-
stackName = generateEphemeralStackName()
14+
stackName = isUsingEphemeralStack ? generateEphemeralStackName() : process.env['STACK_NAME']
1415

15-
console.log(`Starting cloudformation deployment of stack ${stackName}`)
16-
const { stdout } = await exec(`./deploy.sh ${stackName}`)
17-
console.log('Deployment finished')
18-
console.log(stdout)
16+
if (isUsingEphemeralStack) {
17+
console.log(`Starting cloudformation deployment of stack ${stackName}`)
18+
const { stdout } = await exec(`./deploy.sh ${stackName}`)
19+
console.log('Deployment finished')
20+
console.log(stdout)
21+
}
22+
else {
23+
console.log(`Using existing stack ${stackName} as application target`)
24+
}
1925

2026
const cloudformationStacks = await cloudFormation.describeStacks({StackName: stackName}).promise()
2127
const apiID = cloudformationStacks
@@ -52,8 +58,13 @@ function twoCharacter(number) {
5258
}
5359

5460
afterAll(async () => {
55-
console.log(`Calling cloudformation to delete stack ${stackName}`)
56-
await cloudFormation.deleteStack({StackName: stackName}).promise()
61+
if (isUsingEphemeralStack) {
62+
console.log(`Calling cloudformation to delete stack ${stackName}`)
63+
await cloudFormation.deleteStack({StackName: stackName}).promise()
64+
}
65+
else {
66+
console.log(`Leaving stack ${stackName} as deployed`)
67+
}
5768
})
5869

5970
test('API should return 200 exit code and expected content', async () => {

0 commit comments

Comments
 (0)