Skip to content

test: add unit tests for fallback client - #463

Open
Sun-Wukhan wants to merge 2 commits into
jetstack:mainfrom
Sun-Wukhan:test/fallback-client-tests
Open

Sun-Wukhan wants to merge 2 commits into
jetstack:mainfrom
Sun-Wukhan:test/fallback-client-tests

Conversation

@Sun-Wukhan

Copy link
Copy Markdown

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/).

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>
Copilot AI balanced review requested due to automatic review settings October 11, 2026 11:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 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) {
Copilot AI balanced review requested due to automatic review settings November 30, 2026 19:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The test-only additions covering OCI fallback behavior have no active review issues.

2 open issues

Review effort: Balanced

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.

Add OCI support tests

2 participants