fix: mock http server for volcenginecr adapt ut#22810
Merged
wy65701436 merged 5 commits intogoharbor:mainfrom Feb 4, 2026
Merged
fix: mock http server for volcenginecr adapt ut#22810wy65701436 merged 5 commits intogoharbor:mainfrom
wy65701436 merged 5 commits intogoharbor:mainfrom
Conversation
Signed-off-by: Yiyang Huang <691795636@qq.com>
6b67b84 to
bc02207
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the volcenginecr adapter unit tests to use a mock HTTP server instead of connecting to the real Volcengine registry service. This addresses issue #22808 where tests failed due to network timeouts and instability.
Changes:
- Introduced a
resolveHostfunction variable for dependency injection to enable test mocking - Added an HTTP test server in
Test_getRealmServicethat mimics the bearer authentication challenge - Modified
getRealmServiceto use the injectableresolveHostfunction
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/pkg/reg/adapter/volcenginecr/helper.go | Added resolveHost variable function for test injection and modified getRealmService to use it |
| src/pkg/reg/adapter/volcenginecr/helper_test.go | Added mock HTTP server setup and test infrastructure to redirect requests to the mock server |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Yiyang Huang <huangyiyang.huangyy@bytedance.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Yiyang Huang <huangyiyang.huangyy@bytedance.com>
5 tasks
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #22810 +/- ##
===========================================
+ Coverage 45.36% 65.93% +20.56%
===========================================
Files 244 1074 +830
Lines 13333 116415 +103082
Branches 2719 2937 +218
===========================================
+ Hits 6049 76760 +70711
- Misses 6983 35407 +28424
- Partials 301 4248 +3947
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
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.
Thank you for contributing to Harbor!
Comprehensive Summary of your change
Issue being fixed
Fixes #22808
Please indicate you've done the following: