Skip to content

Maintenance: add comments to SecretsProvider integration tests #1279

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
1 of 2 tasks
dreamorosi opened this issue Feb 8, 2023 · 5 comments · Fixed by #1282
Closed
1 of 2 tasks

Maintenance: add comments to SecretsProvider integration tests #1279

dreamorosi opened this issue Feb 8, 2023 · 5 comments · Fixed by #1282
Assignees
Labels
completed This item is complete and has been merged/shipped internal PRs that introduce changes in governance, tech debt and chores (linting setup, baseline, etc.) parameters This item relates to the Parameters Utility

Comments

@dreamorosi
Copy link
Contributor

Summary

In #1263 we have added integration tests for SecretsProvider, part of the upcoming Parameters utility.

We should dedicate some additional cycles to add comments/documentation to the tests to make them future proof and clearer.

Why is this needed?

To allow future maintainers and potential prospect contributors to more easily understand what's going on in the tests, as well as troubleshoot issues.

Which area does this relate to?

Tests, Parameters

Solution

See example of comments in the DynamoDBProvider here.

Acknowledgment

@dreamorosi dreamorosi added internal PRs that introduce changes in governance, tech debt and chores (linting setup, baseline, etc.) parameters This item relates to the Parameters Utility confirmed The scope is clear, ready for implementation labels Feb 8, 2023
@dreamorosi dreamorosi added this to the Parameters - Beta release milestone Feb 8, 2023
@am29d
Copy link
Contributor

am29d commented Feb 8, 2023

I can take this one, since I worked on the PR before.

@dreamorosi
Copy link
Contributor Author

While at it, please also update the imports of the secretsProvider.class.test.functionCode.ts file to:

import {
  SecretsProvider,
} from '../../src/secrets';
import { SecretsGetOptionsInterface } from '../../src/types';

Currently they are pointing to the built/compiled version instead of the source.

And in tests 6 & 7, review the test key in the log emitted within the catch blocks, it should match the one in their respective try.

@dreamorosi
Copy link
Contributor Author

dreamorosi commented Feb 8, 2023

Also, test number 7 we have:

await providerWithMiddleware.get(secretNamePlainChached);
await providerWithMiddleware.get(secretNamePlainChached, { forceFetch: true });

The counter here should be 2 (fetched twice because of using forceFetch), but in the test we are asserting as 1:

it('should retrieve single parameter twice without caching', async () => {
  const logs = invocationLogs[0].getFunctionLogs();
  const testLogFirst = InvocationLogs.parseFunctionLog(logs[6]);

  expect(testLogFirst).toStrictEqual({
    test: 'get-plain-force',
    value: 1 // This should be 2
  });
});

This is happening because we are fetching the same parameter from test 6, so the first time we fetch in test 7 we are still hitting cache, while in the second one we are actually finally fetching.

To fix this we have a few options:

  • manually clear the cache before each test (providerWithMiddleware.clearCache();) - I'd go w/ this one
  • fetch a different secret (so we avoid caching)

Apologies for not spotting these things during my review, I should have done better and I will try to in future ones.

@am29d
Copy link
Contributor

am29d commented Feb 8, 2023

No worries, I also missed this part completely.

Adding providerWithMiddleware.clearCache(); helps to clear the cache and the tests not works with value: 2.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 9, 2023

⚠️ COMMENT VISIBILITY WARNING ⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@github-actions github-actions bot added the pending-release This item has been merged and will be released soon label Feb 9, 2023
@dreamorosi dreamorosi added completed This item is complete and has been merged/shipped and removed pending-release This item has been merged and will be released soon confirmed The scope is clear, ready for implementation labels Feb 9, 2023
@dreamorosi dreamorosi moved this from Coming soon to Shipped in AWS Lambda Powertools for TypeScript Feb 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completed This item is complete and has been merged/shipped internal PRs that introduce changes in governance, tech debt and chores (linting setup, baseline, etc.) parameters This item relates to the Parameters Utility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants