-
Notifications
You must be signed in to change notification settings - Fork 42
test(docker): add unit tests for environment.go #754
Description
Title: test(docker): add unit tests for environment.go
Body:
The internal/docker/environment.go file is responsible for providing environment variables to Docker containers. This is a critical part of the release process, as it ensures that the containers have the correct configuration.
Currently, this file has no unit tests, which makes it difficult to ensure that it correctly handles all environment variable scenarios.
This issue tracks the work to add comprehensive unit tests for the functions in environment.go.
Implementation Guidance
constructEnvironmentFileContent
The tests for constructEnvironmentFileContent should cover the following scenarios:
- Environment variables are correctly sourced from the host environment.
- Environment variables are correctly sourced from Secret Manager when not present in the host environment.
- Default values are used when environment variables are not present in the host environment or Secret Manager.
- The environment file content is correctly formatted.
To test the Secret Manager integration, a mock secrets.SecretsClient should be used to avoid making real API calls.
getSecretManagerValue
The tests for getSecretManagerValue should cover:
- Successfully fetching a secret from Secret Manager.
- Handling the case where a secret is not found in Secret Manager.
- Handling other errors returned by the Secret Manager client.
- Verifying that the secret cache is used correctly.
Acceptance Criteria
- All functions in
internal/docker/environment.gohave unit tests. - The new tests cover both success and error cases.
- The overall test coverage for
environment.gois at least 90%.
Child issue of #202