Skip to content

Commit 5f4ed96

Browse files
committed
integ
tweak
1 parent 313f175 commit 5f4ed96

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

packages/@aws-cdk-testing/cli-integ/resources/cdk-apps/app/app.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,10 @@ switch (stackSet) {
993993
case 'stage-with-no-stacks':
994994
break;
995995

996+
case 'stage-only':
997+
new SomeStage(app, `${stackPrefix}-stage`);
998+
break;
999+
9961000
default:
9971001
throw new Error(`Unrecognized INTEG_STACK_SET: '${stackSet}'`);
9981002
}

packages/@aws-cdk-testing/cli-integ/tests/cli-integ-tests/destroy/cdk-destroy-nonexistent-stack.integtest.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,11 @@ integTest('cdk destroy with no force option exits without prompt if the stacks d
1111
const nonExistingStackName1 = 'non-existing-stack-1';
1212
const nonExistingStackName2 = 'non-existing-stack-2';
1313

14-
await expect(fixture.cdk(['destroy', ...fixture.fullStackName([nonExistingStackName1, nonExistingStackName2])])).resolves.not.toThrow();
14+
await expect(fixture.cdkDestroy([...fixture.fullStackName([nonExistingStackName1, nonExistingStackName2])], {
15+
force: false,
16+
})).resolves.not.toThrow();
1517
}));
1618

1719
integTest('cdk destroy does not fail with wildcard pattern that matches no stacks', withDefaultFixture(async (fixture) => {
1820
await expect(fixture.cdkDestroy('NonExistent*')).resolves.not.toThrow();
1921
}));
20-
21-
integTest('cdk destroy does not fail with --all when no stacks exist', withDefaultFixture(async (fixture) => {
22-
await expect(fixture.cdkDestroy('--all')).resolves.not.toThrow();
23-
}));
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { DescribeStacksCommand } from '@aws-sdk/client-cloudformation';
2+
import { integTest, withDefaultFixture } from '../../../lib';
3+
4+
integTest('cdk destroy can destroy stacks in stage-only configuration', withDefaultFixture(async (fixture) => {
5+
const stageNameSuffix = 'stage';
6+
const specifiedStackName = `${stageNameSuffix}/*`;
7+
8+
await fixture.cdkDeploy(specifiedStackName);
9+
10+
const stackName = `${fixture.fullStackName(stageNameSuffix)}-StackInStage`;
11+
const stack = await fixture.aws.cloudFormation.send(new DescribeStacksCommand({ StackName: stackName }));
12+
expect(stack.Stacks?.length ?? 0).toEqual(1);
13+
14+
await fixture.cdkDestroy(['stage/*'], {
15+
modEnv: {
16+
INTEG_STACK_SET: 'stage-only',
17+
},
18+
});
19+
20+
await expect(fixture.aws.cloudFormation.send(new DescribeStacksCommand({ StackName: stackName })))
21+
.rejects.toThrow(/does not exist/);
22+
}));

0 commit comments

Comments
 (0)