Skip to content

Commit

Permalink
revert(cli): 'deploy' and 'diff' silently does nothing when given unk…
Browse files Browse the repository at this point in the history
…nown stack name (#16125)

Broke integration tests when `synth`ing without providing a stack name

reverts #16073
  • Loading branch information
kaizencc committed Aug 19, 2021
1 parent 2ce274f commit f2d77d3
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 25 deletions.
10 changes: 3 additions & 7 deletions packages/aws-cdk/lib/cdk-toolkit.ts
Expand Up @@ -397,7 +397,7 @@ export class CdkToolkit {
defaultBehavior: DefaultSelection.OnlySingle,
});

await this.validateStacks(stacks, selector.patterns);
await this.validateStacks(stacks);

return stacks;
}
Expand All @@ -415,7 +415,7 @@ export class CdkToolkit {
? allStacks.filter(art => art.validateOnSynth ?? false)
: new StackCollection(assembly, []);

await this.validateStacks(selectedForDiff.concat(autoValidateStacks), stackNames);
await this.validateStacks(selectedForDiff.concat(autoValidateStacks));

return selectedForDiff;
}
Expand All @@ -435,11 +435,7 @@ export class CdkToolkit {
/**
* Validate the stacks for errors and warnings according to the CLI's current settings
*/
private async validateStacks(stacks: StackCollection, stackNames: string[]) {
if (stacks.stackCount == 0) {
throw new Error(`No stacks match the name(s) ${stackNames}`);
}

private async validateStacks(stacks: StackCollection) {
stacks.processMetadataMessages({
ignoreErrors: this.props.ignoreErrors,
strict: this.props.strict,
Expand Down
8 changes: 0 additions & 8 deletions packages/aws-cdk/test/cdk-toolkit.test.ts
Expand Up @@ -39,14 +39,6 @@ function defaultToolkitSetup() {
}

describe('deploy', () => {
test('fails when no valid stack names are given', async () => {
// GIVEN
const toolkit = defaultToolkitSetup();

// WHEN
await expect(() => toolkit.deploy({ selector: { patterns: ['Test-Stack-D'] } })).rejects.toThrow('No stacks match the name(s) Test-Stack-D');
});

describe('makes correct CloudFormation calls', () => {
test('without options', async () => {
// GIVEN
Expand Down
10 changes: 0 additions & 10 deletions packages/aws-cdk/test/diff.test.ts
Expand Up @@ -121,16 +121,6 @@ test('throws an error during diffs on stack with error metadata', async () => {
})).rejects.toThrow(/Found errors/);
});

test('throws an error if no valid stack names given', async () => {
const buffer = new StringWritable();

// WHEN
await expect(() => toolkit.diff({
stackNames: ['X', 'Y', 'Z'],
stream: buffer,
})).rejects.toThrow('No stacks match the name(s) X,Y,Z');
});

class StringWritable extends Writable {
public data: string;
private readonly _decoder: NodeStringDecoder;
Expand Down

0 comments on commit f2d77d3

Please sign in to comment.