refactor(tests): reorganize and enhance test structure for buildhistory and dockercli#47
Conversation
…ry and dockercli - Moved existing tests from internal packages to dedicated test packages for better organization. - Added new tests for buildhistory and dockercli functionalities, including context handling and device login. - Removed outdated tests from internal packages to streamline the codebase and improve maintainability.
|
Warning Review limit reached
Next review available in: 43 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughBackend Go unit tests are converted from in-package tests to external ChangesExternal test package migration
Estimated code review effort: 2 (Simple) | ~12 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/test/dockercli/context_test.go`:
- Around line 39-46: `TestReadCurrentContextFromConfig` now depends on
`dockercli.StatusFor`, which returns early when `exec.LookPath("docker")` fails
and makes the test fail if Docker is not installed. Update the test to avoid
this PATH dependency by either skipping when `docker` is unavailable or testing
the config-reading logic through `readCurrentContext` separately from
`StatusFor`, using the existing `dockercli.StatusFor` and `readCurrentContext`
symbols to keep the coverage focused.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 6c11dae9-e884-48c4-b76d-06475d384918
📒 Files selected for processing (15)
.cursor/rules/calf.mdcCLAUDE.mdbackend/internal/buildhistory/artifacts_test.gobackend/internal/buildhistory/history_test.gobackend/internal/buildhistory/inspect_test.gobackend/internal/migration/compose_migration_test.gobackend/internal/migration/disk_test.gobackend/internal/runtime/inspect_decode_test.gobackend/test/buildhistory/history_test.gobackend/test/dockercli/context_test.gobackend/test/dockerhub/device_test.gobackend/test/runtime/build_enrich_test.gobackend/test/runtime/build_parser_test.gobackend/test/volumeexport/name_pattern_test.gobackend/test/volumeexport/schedule_timing_test.go
💤 Files with no reviewable changes (6)
- backend/internal/buildhistory/artifacts_test.go
- backend/internal/buildhistory/inspect_test.go
- backend/internal/runtime/inspect_decode_test.go
- backend/internal/buildhistory/history_test.go
- backend/internal/migration/compose_migration_test.go
- backend/internal/migration/disk_test.go
| status, err := dockercli.StatusFor("", false) | ||
| if err != nil { | ||
| t.Fatalf("StatusFor() error: %v", err) | ||
| } | ||
|
|
||
| if status.CurrentContext != "calf" { | ||
| t.Fatalf("expected calf, got %q", status.CurrentContext) | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
TestReadCurrentContextFromConfig will fail when docker is not in PATH.
StatusFor calls exec.LookPath("docker") and returns early with an empty CurrentContext if docker isn't found. The original test called readCurrentContext() directly, which had no such dependency. After migrating to StatusFor, this test now implicitly requires docker to be installed — it will fail in any environment where docker is absent.
Consider either skipping the test when docker isn't available, or restructuring so the config-reading path is tested independently of the docker PATH check.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@backend/test/dockercli/context_test.go` around lines 39 - 46,
`TestReadCurrentContextFromConfig` now depends on `dockercli.StatusFor`, which
returns early when `exec.LookPath("docker")` fails and makes the test fail if
Docker is not installed. Update the test to avoid this PATH dependency by either
skipping when `docker` is unavailable or testing the config-reading logic
through `readCurrentContext` separately from `StatusFor`, using the existing
`dockercli.StatusFor` and `readCurrentContext` symbols to keep the coverage
focused.
…n status - Added CurrentContext to the status returned by the StatusFor function, improving context handling. - Removed redundant assignment of CurrentContext to streamline the code.
Summary by CodeRabbit
Documentation
Tests