Skip to content

Commit a6a8025

Browse files
committed
fix(test): make metadata resource test immune to encoding
The prefix-encoded trie could occasionally encode the tested resource name in a way that prevents the test to match. Using a "fake" version number ensures a unique prefix is always present, and hence the tested entry will never be encoded in unexpected ways.
1 parent 4c63f09 commit a6a8025

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

packages/@aws-cdk/core/test/metadata-resource.test.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ describe('MetadataResource', () => {
6363
test('includes constructs added to the stack', () => {
6464
new TestConstruct(stack, 'Test');
6565

66-
expect(stackAnalytics()).toContain('1.2.3!@amzn/core.TestConstruct');
66+
expect(stackAnalytics()).toContain('FakeVersion.2.3!@amzn/core.TestConstruct');
6767
});
6868

6969
test('only includes constructs in the allow list', () => {
@@ -141,11 +141,10 @@ const JSII_RUNTIME_SYMBOL = Symbol.for('jsii.rtti');
141141

142142
class TestConstruct extends Construct {
143143
// @ts-ignore
144-
private static readonly [JSII_RUNTIME_SYMBOL] = { fqn: '@amzn/core.TestConstruct', version: '1.2.3' }
144+
private static readonly [JSII_RUNTIME_SYMBOL] = { fqn: '@amzn/core.TestConstruct', version: 'FakeVersion.2.3' }
145145
}
146146

147147
class TestThirdPartyConstruct extends Construct {
148148
// @ts-ignore
149-
private static readonly [JSII_RUNTIME_SYMBOL] = { fqn: 'mycoolthing.TestConstruct', version: '1.2.3' }
149+
private static readonly [JSII_RUNTIME_SYMBOL] = { fqn: 'mycoolthing.TestConstruct', version: '999.2.3' }
150150
}
151-

0 commit comments

Comments
 (0)