Repository navigation
test: add unit tests for fallback client - #463
Open
Sun-Wukhan wants to merge 1 commit into
Open
Sun-Wukhan wants to merge 1 commit into
Sun-Wukhan wants to merge 1 commit into
Conversation
Closes jetstack#217. Signed-off-by: Navid Khan <ali.n.khan93dev@gmail.com> Signed-off-by: Navid Khan (Ali) <60997541+Sun-Wukhan@users.noreply.github.com>
Sun-Wukhan
requested review from
davidcollom and
maria-reynoso
as code owners
October 11, 2026 11:11
There was a problem hiding this comment.
🟡 Changes recommended
The tests do not exercise the third, OCI-positioned fallback and contain incomplete or misleading cache and failure coverage.
2 open findings
What changed in this PR
Adds unit tests for fallback-client routing, caching, failure handling, and interface methods.
Changes:
- Adds controllable image-client test doubles.
- Tests fallback selection, cache behavior, and errors.
| File | Description |
|---|---|
pkg/client/fallback/fallback_test.go |
Adds fallback-client unit tests. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+60
to
+63
| first := &stubClient{name: "first", err: errors.New("boom")} | ||
| second := &stubClient{name: "second", tags: want} | ||
|
|
||
| c := newTestClient(t, first, second) |
| assert.Equal(t, 2, second.calls) | ||
| } | ||
|
|
||
| func TestTagsCacheMissFallsBackAgain(t *testing.T) { |
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.


Closes #217.
Adds unit tests for the fallback client (
pkg/client/fallback), covering fallback-to-next-client, host-cache hit, cache-miss re-fallback, all-clients-fail error, plus Name/IsHost/RepoImageFromPath. All 8 tests pass locally (go test ./pkg/client/fallback/).