Replace duplicated mockEnvProvider test types with shared environment providers#2014
Open
dgageot wants to merge 1 commit intodocker:mainfrom
Open
Replace duplicated mockEnvProvider test types with shared environment providers#2014dgageot wants to merge 1 commit intodocker:mainfrom
dgageot wants to merge 1 commit intodocker:mainfrom
Conversation
There was a problem hiding this comment.
🟢 Review: COMMENT
Assessment: 🟢 APPROVE
Summary
No bugs found in the changed code. This PR successfully consolidates duplicated test mock code into shared, reusable test helpers.
Changes reviewed:
- Added
MapEnvProviderandNoEnvProvidertopkg/environment/env.go— both correctly implement theProviderinterface with proper nil safety - Removed ~70 lines of duplicated
mockEnvProviderimplementations from 7 test files - All test conversions maintain identical behavior by replacing local mocks with calls to the new shared constructors
- Dependency updates in go.mod/go.sum are routine version bumps
The code is clean, type-safe, and improves maintainability by eliminating test code duplication. ✅
64d3d45 to
4828383
Compare
… providers
Add MapEnvProvider and NoEnvProvider to pkg/environment for use in tests,
replacing 6 nearly identical mockEnvProvider implementations scattered
across test files.
- MapEnvProvider wraps a map[string]string for test env lookups
- NoEnvProvider always returns ("", false) for no-env-available cases
- Remove ~70 lines of duplicated mock boilerplate from 7 test files
Assisted-By: docker-agent
4828383 to
30cfb66
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
MapEnvProviderandNoEnvProvidertopkg/environmentfor use in tests, replacing 6 nearly identicalmockEnvProviderimplementations scattered across test files.MapEnvProviderwraps amap[string]stringfor test env lookupsNoEnvProvideralways returns("", false)for no-env-available casesChanged files
pkg/environment/env.go— addMapEnvProviderandNoEnvProviderpkg/config/auto_test.go— use shared providerspkg/config/sources_test.go— use shared providerspkg/runtime/model_switcher_test.go— use shared providerspkg/model/provider/rulebased/client_test.go— use shared providerspkg/model/provider/custom_provider_test.go— use shared providerspkg/model/provider/bedrock/client_test.go— use shared providerspkg/model/provider/openai/api_type_test.go— use shared providers