From f6b353f3b8f76c559f98df794212221823bf4324 Mon Sep 17 00:00:00 2001 From: Otavio Macedo <288203+otaviomacedo@users.noreply.github.com> Date: Wed, 30 Nov 2022 13:09:07 +0000 Subject: [PATCH] refactor: extracting a variable to make a test more deteministic (#23173) There has been at least one pipeline failure due to a 1 ms difference between the actual and expected values in this test. Extract the expiration value to reuse it for input and expectation. ---- ### All Submissions: * [ ] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) ### Adding new Construct Runtime Dependencies: * [ ] This PR adds new construct runtime dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-construct-runtime-dependencies) ### New Features * [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)? * [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)? *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license* --- packages/@aws-cdk/aws-appsync/test/appsync-auth.test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/@aws-cdk/aws-appsync/test/appsync-auth.test.ts b/packages/@aws-cdk/aws-appsync/test/appsync-auth.test.ts index 4574e365b5151..b220e9d6f2d3b 100644 --- a/packages/@aws-cdk/aws-appsync/test/appsync-auth.test.ts +++ b/packages/@aws-cdk/aws-appsync/test/appsync-auth.test.ts @@ -90,7 +90,8 @@ describe('AppSync API Key Authorization', () => { }); test('apiKeyConfig creates default with valid expiration date', () => { - const expirationDate: number = cdk.Expiration.after(cdk.Duration.days(10)).toEpoch(); + const expires = cdk.Expiration.after(cdk.Duration.days(10)); + const expirationDate: number = expires.toEpoch(); // WHEN new appsync.GraphqlApi(stack, 'API', { @@ -100,7 +101,7 @@ describe('AppSync API Key Authorization', () => { defaultAuthorization: { authorizationType: appsync.AuthorizationType.API_KEY, apiKeyConfig: { - expires: cdk.Expiration.after(cdk.Duration.days(10)), + expires, }, }, },