Skip to content

feat: add SecretManager mocking #265

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

CorieW
Copy link
Member

@CorieW CorieW commented May 12, 2025

Resolves #255

@cabljac cabljac requested a review from Copilot May 19, 2025 10:07
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Adds a utility to mock Secret Manager values in tests by setting environment variables, and re-exports it for easier consumption.

  • Introduce mockSecretManager to populate process.env from a config object.
  • Re-export the helper in src/main.ts for public API access.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/secretManager.ts Implements mockSecretManager to load mock secrets into process.env.
src/main.ts Adds export { mockSecretManager } for external use.
Comments suppressed due to low confidence (1)

src/secretManager.ts:2

  • There are currently no tests covering mockSecretManager. Add unit tests to verify it sets the expected environment variables and does not leak between test runs.
export function mockSecretManager(conf: { [key: string]: any }) {

Copy link
Contributor

@cabljac cabljac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small change to improve types

Also maybe worth adding some simple tests on this, so behaviour is protected

@taeold
Copy link
Contributor

taeold commented May 19, 2025

@cabljac +1 on testing

@cabljac cabljac requested a review from Copilot May 21, 2025 15:50
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a SecretManager mocking functionality to help with testing functions that rely on secret configuration values. Key changes include:

  • New helper function (mockSecretManager) in src/secretManager.ts to set process.env variables.
  • Export of the new function in src/main.ts.
  • Comprehensive test cases in spec/secretmanager.spec.ts and corresponding import in spec/index.spec.ts.

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
src/secretManager.ts Introduces mockSecretManager to simulate secret configurations.
src/main.ts Exports mockSecretManager for external usage.
spec/secretmanager.spec.ts Provides tests validating the functionality of mockSecretManager.
spec/index.spec.ts Updates test index to include secretmanager.spec.ts.

Copy link
Contributor

@cabljac cabljac left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@github-project-automation github-project-automation bot moved this from Changes Requested [PR] to Approved [PR] in [Cloud] Extensions + Functions May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Secret Manager Values in offline testing
3 participants