Skip to content

refactor(tests): reorganize and enhance test structure for buildhistory and dockercli#47

Merged
enegalan merged 2 commits into
mainfrom
reorganize_tests
Jul 9, 2026
Merged

refactor(tests): reorganize and enhance test structure for buildhistory and dockercli#47
enegalan merged 2 commits into
mainfrom
reorganize_tests

Conversation

@enegalan

@enegalan enegalan commented Jul 9, 2026

Copy link
Copy Markdown
Owner
  • 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.

Summary by CodeRabbit

  • Documentation

    • Expanded the documented backend test layout to include additional coverage areas, giving a more complete view of the project structure.
  • Tests

    • Added new coverage for build history parsing and duplicate handling.
    • Updated several test suites to run through public-facing interfaces.
    • Removed a number of older internal tests while keeping broader external test coverage in place.

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

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@enegalan, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 43 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: aaf5d5a7-7528-44d0-b9cf-a581a4884790

📥 Commits

Reviewing files that changed from the base of the PR and between 7afb754 and 3206244.

📒 Files selected for processing (1)
  • backend/internal/dockercli/context.go
📝 Walkthrough

Walkthrough

Backend Go unit tests are converted from in-package tests to external _test packages across buildhistory, dockercli, runtime, and volumeexport, qualifying calls through imported packages. Some internal test files (buildhistory artifacts/history/inspect, migration compose/disk, runtime inspect_decode) are removed. Documentation of the test directory layout is expanded.

Changes

External test package migration

Layer / File(s) Summary
Documented project layout updates
.cursor/rules/calf.mdc, CLAUDE.md
Backend test directory listings expanded to include buildhistory, buildstore, dockercli, dockerhub, volumeexport, and a broader runtime test subtree.
Removal of internal test files
backend/internal/buildhistory/artifacts_test.go, backend/internal/buildhistory/history_test.go, backend/internal/buildhistory/inspect_test.go, backend/internal/migration/compose_migration_test.go, backend/internal/migration/disk_test.go, backend/internal/runtime/inspect_decode_test.go
In-package unit tests for buildhistory, migration, and runtime are deleted.
New external buildhistory tests
backend/test/buildhistory/history_test.go
Adds TestParseDurationMs and TestMergeRowsSkipsDuplicates against the exported buildhistory package.
dockercli tests moved externally
backend/test/dockercli/context_test.go
Switches to package dockercli_test, replacing direct readCurrentContext checks with dockercli.StatusFor assertions.
runtime tests moved externally
backend/test/runtime/build_enrich_test.go, backend/test/runtime/build_parser_test.go
Switches to package runtime_test, qualifies calls via the imported runtime package, and removes TestParseDockerfileDependencies which used an unexported function.
volumeexport tests moved externally
backend/test/volumeexport/name_pattern_test.go, backend/test/volumeexport/schedule_timing_test.go
Switches to package volumeexport_test, qualifies Schedule/ComputeNextRun/ScheduleDue/name-pattern calls, and adds a static schedule FileName-preservation case.

Estimated code review effort: 2 (Simple) | ~12 minutes

Possibly related PRs

  • enegalan/calf#19: Removed inspect_decode tests correspond to the decodeInspectDocuments implementation introduced there.
  • enegalan/calf#37: buildhistory test migration/removal corresponds to the buildhistory modules and logic introduced there.
  • enegalan/calf#38: volumeexport test migration aligns with the volume export scheduling/name-pattern functionality added there.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main test refactor and mentions two primary affected areas, even though it does not cover every package.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch reorganize_tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7e6f748 and 7afb754.

📒 Files selected for processing (15)
  • .cursor/rules/calf.mdc
  • CLAUDE.md
  • backend/internal/buildhistory/artifacts_test.go
  • backend/internal/buildhistory/history_test.go
  • backend/internal/buildhistory/inspect_test.go
  • backend/internal/migration/compose_migration_test.go
  • backend/internal/migration/disk_test.go
  • backend/internal/runtime/inspect_decode_test.go
  • backend/test/buildhistory/history_test.go
  • backend/test/dockercli/context_test.go
  • backend/test/dockerhub/device_test.go
  • backend/test/runtime/build_enrich_test.go
  • backend/test/runtime/build_parser_test.go
  • backend/test/volumeexport/name_pattern_test.go
  • backend/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

Comment on lines +39 to 46
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)
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 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.
@enegalan enegalan merged commit 0454e75 into main Jul 9, 2026
3 checks passed
@enegalan enegalan deleted the reorganize_tests branch July 9, 2026 16:49
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.

1 participant