Skip to content

[scanner] fix: expand test coverage for stellar/providers registry#19224

Merged
clubanderson merged 2 commits into
mainfrom
scanner/fix-18763
Jun 19, 2026
Merged

[scanner] fix: expand test coverage for stellar/providers registry#19224
clubanderson merged 2 commits into
mainfrom
scanner/fix-18763

Conversation

@clubanderson

Copy link
Copy Markdown
Collaborator

Fixes #18763

Expands test coverage for pkg/stellar/providers/registry.go from ~30% (happy paths only) to comprehensive error-path and edge-case coverage.

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)

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>
Copilot AI review requested due to automatic review settings June 19, 2026 17:56
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Jun 19, 2026
@kubestellar-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign mikespreitzer for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@netlify

netlify Bot commented Jun 19, 2026

Copy link
Copy Markdown

Deploy Preview for kubestellarconsole canceled.

Name Link
🔨 Latest commit 931c79c
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/6a35874f16184e0009d35a5e

@github-actions

Copy link
Copy Markdown
Contributor

👋 Hey @clubanderson — thanks for opening this PR!

🤖 This project is developed exclusively using AI coding assistants.

Please do not attempt to code anything for this project manually.
All contributions should be authored using an AI coding tool such as:

This ensures consistency in code style, architecture patterns, test coverage,
and commit quality across the entire codebase.


This is an automated message.

@github-actions

Copy link
Copy Markdown
Contributor

🐝 Hi @clubanderson! I'm kubestellar-hive[bot], an automation bot for this repo.

Trusted users — org members and contributors with write access — can mention @kubestellar-hive in a comment to trigger repo automation.
On issues, that mention queues an automated fix attempt. On pull requests, it records extra context for existing automation.
This is not an interactive Q&A bot, so mentions should be treated as requests for automation rather than a conversation.

Automation may take a moment to start, and follow-up happens through workflow activity rather than chat replies.

@kubestellar-prow kubestellar-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 19, 2026

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.

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.Resolve fallback/edge-case behavior (unknown request provider, nil user provider, missing default, empty registry).
  • Added tests for Registry.ResolveScannerProvider edge cases (cancelled context, nil context, no fallback provider).
  • Added tests for Register, ListProviderInfo, displayName, and a concurrent-read access scenario.

Comment on lines +140 to +144
_, _, err := r.ResolveScannerProvider(context.Background(), "user-1")
if err == nil {
t.Fatal("expected error when no fallback provider available")
}
}
Comment on lines +1 to +7
package providers

import (
"context"
"sync"
"testing"
)
@clubanderson clubanderson merged commit 0674513 into main Jun 19, 2026
21 of 27 checks passed
@kubestellar-prow kubestellar-prow Bot deleted the scanner/fix-18763 branch June 19, 2026 18:16
@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Your PR has been merged.

Check out what's new:

Stay connected: Slack #kubestellar-dev | Multi-Cluster Survey

@github-actions

Copy link
Copy Markdown
Contributor

Post-merge build verification passed

Both Go and frontend builds compiled successfully against merge commit 0674513f6e9a9dbafcd407aa333f567215581c69.

@github-actions

Copy link
Copy Markdown
Contributor

✅ Post-Merge Verification: passed

Commit: 0674513f6e9a9dbafcd407aa333f567215581c69
Specs run: smoke.spec.ts
Report: https://github.com/kubestellar/console/actions/runs/27841809447

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tier/1-lightweight

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[quality] stellar/providers.go coverage at ~30% — TestProvider, CIDR helpers, and CRUD handlers untested

2 participants