From e9cd1e84df3a99bca4ac98890c729f8dec899fd7 Mon Sep 17 00:00:00 2001 From: Romain Marcadier Date: Thu, 11 Mar 2021 11:20:26 +0100 Subject: [PATCH] chore(test): make metadata resource test immune to encoding (#13538) 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. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- 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' } } -