-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(toolkit): only fail if errors are on selected stacks
If we report synthesis errors, they should only prevent the affected stack from deploying; right now, since they are checked during the synthesis step, they would abort the entire toolkit run regardless of whether they would be selected or not. Makes it possible to do region-dependent verification. Fixes #1784. ALSO IN THIS COMMIT If the 'cdk synth' output goes to the screen, don't automatically select upstream stacks for synthesis (as that would lead to an immediate error). Fixes #1783.
- Loading branch information
Rico Huijbers
committed
Feb 20, 2019
1 parent
5dec01a
commit a544e32
Showing
4 changed files
with
142 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import cxapi = require('@aws-cdk/cx-api'); | ||
import { Test } from 'nodeunit'; | ||
import { SDK } from '../../lib'; | ||
import { AppStacks, ExtendedStackSelection } from '../../lib/api/cxapp/stacks'; | ||
import { Configuration } from '../../lib/settings'; | ||
|
||
const FIXED_RESULT: cxapi.SynthesizeResponse = { | ||
version: '1', | ||
stacks: [ | ||
{ | ||
name: 'withouterrors', | ||
template: { resource: 'noerrorresource' }, | ||
environment: { name: 'dev', account: '12345', region: 'here' }, | ||
metadata: {}, | ||
}, | ||
{ | ||
name: 'witherrors', | ||
template: { resource: 'errorresource' }, | ||
environment: { name: 'dev', account: '12345', region: 'here' }, | ||
metadata: { | ||
'/resource': [ | ||
{ | ||
type: cxapi.ERROR_METADATA_KEY, | ||
data: 'this is an error', | ||
trace: [] | ||
} | ||
] | ||
} | ||
} | ||
] | ||
}; | ||
|
||
export = { | ||
async 'do not throw when selecting stack without errors'(test: Test) { | ||
// GIVEN | ||
const stacks = new AppStacks({ | ||
configuration: new Configuration(), | ||
aws: new SDK(), | ||
synthesizer: async () => FIXED_RESULT, | ||
}); | ||
|
||
// WHEN | ||
const selected = await stacks.selectStacks(['withouterrors'], ExtendedStackSelection.None); | ||
|
||
// THEN | ||
test.equal(selected[0].template.resource, 'noerrorresource'); | ||
|
||
test.done(); | ||
}, | ||
|
||
async 'do throw when selecting stack with errors'(test: Test) { | ||
// GIVEN | ||
const stacks = new AppStacks({ | ||
configuration: new Configuration(), | ||
aws: new SDK(), | ||
synthesizer: async () => FIXED_RESULT, | ||
}); | ||
|
||
// WHEN | ||
try { | ||
await stacks.selectStacks(['witherrors'], ExtendedStackSelection.None); | ||
test.ok(false, 'Did not get exception'); | ||
} catch (e) { | ||
test.ok(/Found errors/.test(e.toString()), 'Wrong error'); | ||
} | ||
|
||
test.done(); | ||
}, | ||
}; |