Skip to content

[quality] add unit tests for server_routes.go, shell_unix.go, and init.go#19940

Merged
clubanderson merged 3 commits into
mainfrom
quality/test-routes-shell-2
Jun 29, 2026
Merged

[quality] add unit tests for server_routes.go, shell_unix.go, and init.go#19940
clubanderson merged 3 commits into
mainfrom
quality/test-routes-shell-2

Conversation

@clubanderson

Copy link
Copy Markdown
Collaborator

Test Improvement

Adds 17 test cases across 3 new test files for the remaining untested files in pkg/agent identified in #19907:

server_routes_test.go (4 tests)

  • AllExpectedRoutesRegistered: Verifies all 100+ expected route patterns are registered by registerRoutes — catches accidentally dropped routes during refactors
  • CatchallReturns404ForUnknownPaths: Verifies the catch-all / handler returns 404 for unregistered paths
  • CatchallHandlesOPTIONS: Verifies OPTIONS preflight on the catch-all returns 204
  • RouteCount: Guards against accidental route removal (minimum 100 routes expected)

shell_unix_test.go (5 tests)

  • ResolveShell_ReturnsValidPath: Verifies resolveShell returns a valid executable path
  • ResolveShell_PrefersBash: Verifies bash is preferred over sh when available
  • ShellFlag_ReturnsMinusC: Verifies shellFlag() returns "-c" on Unix
  • IsWindows_ReturnsFalseOnUnix: Verifies isWindows() returns false on non-Windows builds
  • ErrNoShellFound_Message: Verifies the sentinel error message is stable

init_test.go (4 tests + 4 sub-checks)

  • WiresAIPackageFunctionPointers: Verifies init() wires up all 4 function pointers in pkg/ai
  • GetRegistryReturnsNonNil: Verifies the wired GetRegistry returns a valid registry
  • GetConfigManagerReturnsNonNil: Verifies the wired GetConfigManager returns non-nil
  • SetClusterContextProvidersDoesNotPanic: Verifies nil args don't panic

These tests cover server_routes.go, shell.go, shell_unix.go, and init.go — the remaining 4 files from #19907 not addressed by PR #19937 (compat files) or the provider test PRs.

Partially addresses #19907


Filed by quality agent (ACMM L4/L6 — full mode)

clubanderson and others added 3 commits June 29, 2026 15:13
Signed-off-by: clubanderson <clubanderson@users.noreply.github.com>

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Tests resolveShell, shellFlag, isWindows on Unix platforms.

Signed-off-by: clubanderson <clubanderson@users.noreply.github.com>

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Verifies that init() correctly wires up ai.GetRegistry,
ai.InitializeProviders, ai.SetClusterContextProviders, and
ai.GetConfigManager function pointers.

Signed-off-by: clubanderson <clubanderson@users.noreply.github.com>

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 29, 2026 19:14
@kubestellar-prow kubestellar-prow Bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Jun 29, 2026
@netlify

netlify Bot commented Jun 29, 2026

Copy link
Copy Markdown

Deploy Preview for kubestellarconsole canceled.

Name Link
🔨 Latest commit 5fb2b8b
🔍 Latest deploy log https://app.netlify.com/projects/kubestellarconsole/deploys/6a42c415d42c5b000879d83c

@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

@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.

@github-actions github-actions Bot added the ai-generated Pull request generated by AI label Jun 29, 2026
@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.

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

Adds new unit tests to increase pkg/agent coverage for route registration, Unix shell resolution helpers, and pkg/ai function-pointer wiring via init().

Changes:

  • Adds Unix-only tests validating resolveShell(), shellFlag(), isWindows(), and errNoShellFound behavior.
  • Adds tests around Server.registerRoutes() including catch-all behavior (404/OPTIONS).
  • Adds tests verifying init() wires pkg/ai function pointers and that key accessors return non-nil values.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
pkg/agent/server_routes_test.go New tests intended to validate route registration and catch-all behavior for the agent HTTP mux.
pkg/agent/shell_unix_test.go New Unix-only tests for shell detection and platform helpers.
pkg/agent/init_test.go New tests verifying init() wiring between pkg/agent and pkg/ai via function pointers.

Comment on lines +147 to +152
req := httptest.NewRequest(http.MethodGet, route, nil)
// ServeMux.Handler returns the handler and the matched pattern.
_, pattern := mux.Handler(req)
if pattern == "" {
t.Errorf("route %q is not registered in registerRoutes", route)
}
@clubanderson clubanderson merged commit 1405535 into main Jun 29, 2026
39 of 41 checks passed
@kubestellar-prow kubestellar-prow Bot deleted the quality/test-routes-shell-2 branch June 29, 2026 19:25
@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 Verification: cancelled

Commit: 1405535cc5d968d62153ef113a8aa437f5cb1a5f
Specs run: smoke.spec.ts
Report: https://github.com/kubestellar/console/actions/runs/28397081639

@github-actions

Copy link
Copy Markdown
Contributor

Post-merge build verification passed

Both Go and frontend builds compiled successfully against merge commit 1405535cc5d968d62153ef113a8aa437f5cb1a5f.

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

Labels

ai-generated Pull request generated by AI 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.

2 participants