[scanner] fix: expand test coverage for stellar/providers registry#19224
Conversation
Adds comprehensive error-path and edge-case tests: Resolve edge cases: - Unknown request provider falls through to user config - Nil user provider falls through to env-default - Default name missing from global map triggers last-resort fallback - Completely empty registry returns nil provider ResolveScannerProvider edge cases: - Cancelled context returns context.Canceled error - Nil context (converted internally, no panic) - No fallback provider returns descriptive error Register: - New provider without setting as default - Register as default updates name and model - Register with empty models list preserves default model ListProviderInfo: - Normal operation with multiple providers - Empty registry returns empty slice displayName: - Known provider names return display strings - Unknown names pass through unchanged Concurrent access: - Parallel Resolve + Available + ListProviderInfo (race detector safe) Signed-off-by: Andy Anderson <andy@clubanderson.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
✅ Deploy Preview for kubestellarconsole canceled.
|
|
👋 Hey @clubanderson — thanks for opening this PR!
This is an automated message. |
|
🐝 Hi @clubanderson! I'm Trusted users — org members and contributors with write access — can mention Automation may take a moment to start, and follow-up happens through workflow activity rather than chat replies. |
There was a problem hiding this comment.
Pull request overview
This PR adds a new Go test suite to substantially increase coverage of pkg/stellar/providers/registry.go, focusing on error paths, edge cases, and basic concurrency safety checks around provider resolution and registry querying.
Changes:
- Added tests for
Registry.Resolvefallback/edge-case behavior (unknown request provider, nil user provider, missing default, empty registry). - Added tests for
Registry.ResolveScannerProvideredge cases (cancelled context, nil context, no fallback provider). - Added tests for
Register,ListProviderInfo,displayName, and a concurrent-read access scenario.
| _, _, err := r.ResolveScannerProvider(context.Background(), "user-1") | ||
| if err == nil { | ||
| t.Fatal("expected error when no fallback provider available") | ||
| } | ||
| } |
| package providers | ||
|
|
||
| import ( | ||
| "context" | ||
| "sync" | ||
| "testing" | ||
| ) |
|
Thank you for your contribution! Your PR has been merged. Check out what's new:
Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey |
|
Post-merge build verification passed ✅ Both Go and frontend builds compiled successfully against merge commit |
✅ Post-Merge Verification: passedCommit: |
Fixes #18763
Expands test coverage for
pkg/stellar/providers/registry.gofrom ~30% (happy paths only) to comprehensive error-path and edge-case coverage.Resolve edge cases:
ResolveScannerProvider edge cases:
Register:
ListProviderInfo:
displayName:
Concurrent access: