Skip to content

Commit

Permalink
refactor: extracting a variable to make a test more deteministic (#23173
Browse files Browse the repository at this point in the history
)

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*
  • Loading branch information
otaviomacedo authored Nov 30, 2022
1 parent d6ede1a commit f6b353f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/@aws-cdk/aws-appsync/test/appsync-auth.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand All @@ -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,
},
},
},
Expand Down

0 comments on commit f6b353f

Please sign in to comment.