-
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(code): make CfnResource#_toCloudFormation null-safe (#3121)
The `CfnResource#_toCloudFormation` method creates a `PostResolveToken` with a post-processor that was not ready to handle the absence of `Properties` on the resolved value. It is however possible that `Properties` are missing when an object is created with the default configuration (e.g: by `new sqs.CfnQueue(this, 'Queue');`). This change makes the post-processor function correctly handle `undefined` in this case. Related #3093
- Loading branch information
1 parent
d40fd05
commit 71cb421
Showing
2 changed files
with
31 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import nodeunit = require('nodeunit'); | ||
import core = require('../lib'); | ||
|
||
export = nodeunit.testCase({ | ||
'._toCloudFormation': { | ||
'does not call renderProperties with an undefined value'(test: nodeunit.Test) { | ||
const app = new core.App(); | ||
const stack = new core.Stack(app, 'TestStack'); | ||
const resource = new core.CfnResource(stack, 'DefaultResource', { type: 'Test::Resource::Fake' }); | ||
|
||
let called = false; | ||
(resource as any).renderProperties = (val: any) => { | ||
called = true; | ||
test.notEqual(val, null); | ||
}; | ||
|
||
test.deepEqual(app.synth().getStack(stack.stackName).template, { | ||
Resources: { | ||
DefaultResource: { | ||
Type: 'Test::Resource::Fake' | ||
} | ||
} | ||
}); | ||
test.ok(called, `renderProperties must be called called`); | ||
|
||
test.done(); | ||
} | ||
} | ||
}); |