From 533e6557f85d9614f45b60ac86497b02fb4c67ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=F0=9F=91=A8=F0=9F=8F=BB=E2=80=8D=F0=9F=92=BB=20Romain=20M?= =?UTF-8?q?arcadier?= Date: Thu, 11 Mar 2021 10:42:06 +0100 Subject: [PATCH] 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. --- packages/@aws-cdk/core/test/metadata-resource.test.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/@aws-cdk/core/test/metadata-resource.test.ts b/packages/@aws-cdk/core/test/metadata-resource.test.ts index 2275bcf7dee9d..00869746b1e25 100644 --- a/packages/@aws-cdk/core/test/metadata-resource.test.ts +++ b/packages/@aws-cdk/core/test/metadata-resource.test.ts @@ -63,7 +63,7 @@ describe('MetadataResource', () => { test('includes constructs added to the stack', () => { new TestConstruct(stack, 'Test'); - expect(stackAnalytics()).toContain('1.2.3!@amzn/core.TestConstruct'); + expect(stackAnalytics()).toContain('FakeVersion.2.3!@amzn/core.TestConstruct'); }); test('only includes constructs in the allow list', () => { @@ -141,11 +141,10 @@ const JSII_RUNTIME_SYMBOL = Symbol.for('jsii.rtti'); class TestConstruct extends Construct { // @ts-ignore - private static readonly [JSII_RUNTIME_SYMBOL] = { fqn: '@amzn/core.TestConstruct', version: '1.2.3' } + private static readonly [JSII_RUNTIME_SYMBOL] = { fqn: '@amzn/core.TestConstruct', version: 'FakeVersion.2.3' } } class TestThirdPartyConstruct extends Construct { // @ts-ignore private static readonly [JSII_RUNTIME_SYMBOL] = { fqn: 'mycoolthing.TestConstruct', version: '1.2.3' } } -