Skip to content

test(cmd): split test files above the 500-line ceiling - #2282

Merged
cristim merged 50 commits into
mainfrom
test/1536-split-test-files
Oct 20, 2026
Merged

cristim merged 50 commits into
mainfrom
test/1536-split-test-files

Conversation

@cristim

@cristim cristim commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

Closes #1536

These are pure-move splits of the cmd/ test files above the 500-line ceiling. Whole test functions, helpers and fixtures move into new _test.go files in the same package, and only imports are adjusted. Nothing moved out of TestMain, init(), or the shared fixtures in main_test.go and archera_comparison_test.go.

15 files were over 500 lines; all are now at or under it:

File Before After
multi_service 1865 472
helpers 1420 416
main 1356 468
multi_service_filters 1029 361
engine_versions 987 433
multi_service_csv 986 429
max_instances 908 430
multi_service_helpers 899 462
validators 819 473
multi_service_coverage 789 474
configure 713 381
archera_comparison 676 484
multi_service_stats 595 494
extended_support_unavailable 512 458
configure_gcp 503 465

Evidence:

  • Commits: 50, the largest 398 lines. A 209-line test is moved in two steps: copy under a temporary name, then delete the original and rename the copy.
  • Pure move: after every commit, the sorted top-level declaration list across cmd/*_test.go equals main's (844 entries).
  • Tests: the count is 525 before and after, and go test ./... and golangci-lint pass.

Secrets-scanner path updates follow the moved fixtures, and stale entries are removed in the last commit:

  • .gitallowed: the account-ID, {Account: ...} and private_key path lists now name exactly the files that hold those fixtures.
  • .pre-commit-config.yaml: configure_gcp_store_test.go (the PEM-shaped dummy keys) is added to the detect-private-key exclude.
  • No pattern is broadened, and the git-secrets allowlist script reports 44 PASS.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Tests
    • Expanded automated coverage for credential storage, service configuration, filtering, recommendation sizing, CSV workflows, purchase auditing, and validation.
    • Added regression coverage for API-key redaction, extended-support handling, Savings Plan region behavior, account-name caching, and purchase limits.
    • Added checks for CSV totals, sorting, formatting, file errors, confirmation flows, and audit records.
    • Consolidated related test coverage into focused suites to improve maintainability.

cristim and others added 30 commits October 20, 2026 02:35
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…run tests

Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ers_test

Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…main_test

Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cristim and others added 20 commits October 20, 2026 04:51
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ixtures

Pure move of whole test declarations; no logic, assertion or name changes (issue #1536).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: LeanerCloud/cloud-commitments-cli/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 637739a6-0f2a-4ebf-abea-74bb72965106
📥 Commits

Reviewing files that changed from the base of the PR and between 507adee and 43f5add.

📒 Files selected for processing: 58
  • .gitallowed
  • .pre-commit-config.yaml
  • cmd/archera_comparison_masking_test.go
  • cmd/archera_comparison_test.go
  • cmd/configure_azure_store_test.go
  • cmd/configure_gcp_step_test.go
  • cmd/configure_gcp_store_test.go
  • cmd/configure_gcp_test.go
  • cmd/configure_test.go
  • cmd/helpers_account_alias_test.go
  • cmd/helpers_adjust_existing_test.go
  • cmd/helpers_instance_limit_test.go
  • cmd/helpers_target_coverage_guards_test.go
  • cmd/helpers_target_coverage_test.go
  • cmd/helpers_test.go
  • cmd/main_flags_validation_test.go
  • cmd/main_parse_services_test.go
  • cmd/main_purchase_id_comprehensive_test.go
  • cmd/main_purchase_id_test.go
  • cmd/main_service_client_test.go
  • cmd/main_test.go
  • cmd/multi_service_account_names_test.go
  • cmd/multi_service_adjust_excluded_versions_test.go
  • cmd/multi_service_apply_filters_test.go
  • cmd/multi_service_coverage_extended_support_test.go
  • cmd/multi_service_coverage_major_versions_test.go
  • cmd/multi_service_coverage_test.go
  • cmd/multi_service_csv_coverage_column_test.go
  • cmd/multi_service_csv_formatters_test.go
  • cmd/multi_service_csv_report_test.go
  • cmd/multi_service_csv_test.go
  • cmd/multi_service_csv_total_row_test.go
  • cmd/multi_service_csv_write_failure_test.go
  • cmd/multi_service_determine_services_test.go
  • cmd/multi_service_engine_versions_test.go
  • cmd/multi_service_extended_support_unavailable_test.go
  • cmd/multi_service_extended_support_wiring_test.go
  • cmd/multi_service_extract_major_version_test.go
  • cmd/multi_service_filter_adjust_test.go
  • cmd/multi_service_filters_pool_size_test.go
  • cmd/multi_service_filters_savings_plans_test.go
  • cmd/multi_service_filters_test.go
  • cmd/multi_service_from_csv_audit_test.go
  • cmd/multi_service_from_csv_test.go
  • cmd/multi_service_helpers_test.go
  • cmd/multi_service_max_instances_csv_order_test.go
  • cmd/multi_service_max_instances_csv_test.go
  • cmd/multi_service_max_instances_test.go
  • cmd/multi_service_process_service_test.go
  • cmd/multi_service_purchase_loop_test.go
  • cmd/multi_service_regions_test.go
  • cmd/multi_service_should_include_test.go
  • cmd/multi_service_stats_comparison_test.go
  • cmd/multi_service_stats_test.go
  • cmd/multi_service_test.go
  • cmd/validators_coverage_test.go
  • cmd/validators_file_paths_test.go
  • cmd/validators_test.go
💤 Files with no reviewable changes: 15
  • cmd/multi_service_stats_test.go
  • cmd/configure_gcp_test.go
  • cmd/multi_service_csv_test.go
  • cmd/multi_service_extended_support_unavailable_test.go
  • cmd/configure_test.go
  • cmd/multi_service_max_instances_test.go
  • cmd/multi_service_coverage_test.go
  • cmd/main_test.go
  • cmd/multi_service_engine_versions_test.go
  • cmd/multi_service_helpers_test.go
  • cmd/helpers_test.go
  • cmd/validators_test.go
  • cmd/multi_service_filters_test.go
  • cmd/archera_comparison_test.go
  • cmd/multi_service_test.go

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

📝 Walkthrough

The pull request reorganizes CLI Go tests into behavior-focused files. It adds coverage for credential storage, error masking, helpers, validation, multi-service behavior, CSV flows, and purchase processing. It also updates private-key and synthetic account-ID fixture allow-lists.

Changes: CLI Test Suite Reorganization

Layer / File(s) Summary
Credential configuration tests
cmd/configure_azure_store_test.go, cmd/configure_gcp_store_test.go, cmd/configure_gcp_step_test.go, cmd/configure_test.go, cmd/configure_gcp_test.go, .gitallowed, .pre-commit-config.yaml
Credential storage and GCP service-account tests are grouped in focused files. Fixture allow-lists and the private-key hook exclusion are updated for the new GCP test file.
Archera error-masking tests
cmd/archera_comparison_masking_test.go, cmd/archera_comparison_test.go
Archera error-redaction, sanitization, truncation, retry-message, and logging tests are grouped in a dedicated test file. Their former test block is removed from the older file.
Helper tests
cmd/helpers_*_test.go, cmd/helpers_test.go
Account-alias caching, recommendation adjustment, instance limits, and target-coverage tests are organized in focused files. Related tests are removed from helpers_test.go.
CLI parsing and purchase-ID tests
cmd/main_*_test.go, cmd/main_test.go
Tests for flag validation, service parsing, service clients, account-name sanitization, instance-type validation, and purchase-ID generation are grouped in focused files. The corresponding blocks are removed from main_test.go.
Multi-service filtering and coverage tests
cmd/multi_service_account_names_test.go, cmd/multi_service_adjust_excluded_versions_test.go, cmd/multi_service_apply_filters_test.go, cmd/multi_service_coverage_*_test.go, cmd/multi_service_determine_services_test.go, cmd/multi_service_extract_major_version_test.go, cmd/multi_service_filters_*_test.go, cmd/multi_service_regions_test.go, cmd/multi_service_should_include_test.go, cmd/multi_service_helpers_test.go, cmd/multi_service_test.go, cmd/multi_service_engine_versions_test.go
Focused tests cover account-name population, filtering, service selection, region discovery, extended-support adjustment, and engine-version handling. Corresponding blocks are removed from the former shared test files.
CSV reporting and instance-cap tests
cmd/multi_service_csv_*_test.go, cmd/multi_service_csv_test.go, cmd/multi_service_max_instances_csv*_test.go, cmd/multi_service_max_instances_test.go
CSV formatter, report, load, and write-failure tests are grouped in dedicated files. CSV instance-cap and minimum-count tests are also grouped separately from the older shared files.
Multi-service execution and purchase-flow tests
cmd/multi_service_from_csv*_test.go, cmd/multi_service_process_service_test.go, cmd/multi_service_purchase_loop_test.go, cmd/multi_service_extended_support_*_test.go, cmd/multi_service_stats*_test.go, cmd/multi_service_test.go
Tests cover service setup, purchase loops, CSV execution and audit records, extended-support wiring, and comparison output. Related test blocks are removed from shared files.
Validator tests
cmd/validators_*_test.go, cmd/validators_test.go
File-path and coverage-related validator tests are grouped in focused files. Their former blocks and unused imports are removed from validators_test.go.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Other

Merge Risk: ⚪ Minimal · up to 43f5a

This change reorganizes CLI tests into smaller, behavior-focused files without changing product behavior. The same set of tests exists before and after the split, so the change carries no meaningful merge risk.

Pre-merge checks: Passed 3 · Failed 1 · Inconclusive 1

Failed Failed checks: 1 warning · 1 inconclusive

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 44.83% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 145 functions across 41 files. (2 skipped… Write docstrings for the functions missing them to satisfy the coverage threshold.
Linked Issues check Inconclusive For issue [#1536], the evidence supports the file split: the 15 reported oversized cmd/*_test.go files are at or below 500 lines, declaration lists and test counts remain unchanged, and the changes … Provide the go test ./... -count=1 result and the before-and-after coverage comparison for the merge base and reviewed head.
Passed Passed checks: 3 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: splitting oversized cmd test files to meet the 500-line limit.
Out of Scope Changes check Passed The changes stay within issue [#1536]. They move tests within cmd/ and update .gitallowed and .pre-commit-config.yaml for fixtures moved by the split. The evidence shows no production changes an…
Full details: Out of Scope Changes check

Explanation

The changes stay within issue [#1536]. They move tests within cmd/ and update .gitallowed and .pre-commit-config.yaml for fixtures moved by the split. The evidence shows no production changes and no mcp/tools work. The scanner updates support the moved test fixtures.

Full details: Docstring Coverage

Explanation

Docstring coverage is 44.83% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 145 functions across 41 files. (2 skipped: 2 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Full details: Linked Issues check

Explanation

For issue [#1536], the evidence supports the file split: the 15 reported oversized cmd/*_test.go files are at or below 500 lines, declaration lists and test counts remain unchanged, and the changes are test-file moves. The evidence reports go test ./... and golangci-lint, but it does not establish the required go test ./... -count=1 result or provide a before-and-after coverage comparison. Therefore, no coverage loss cannot be established. The small-PR preference is process guidance, not a coding requirement for this assessment.

Resolution

Provide the go test ./... -count=1 result and the before-and-after coverage comparison for the merge base and reviewed head.

  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@cristim

cristim commented Oct 20, 2026

Copy link
Copy Markdown
Member Author

Review V (independent, claude-cc-libs-rev-V): APPROVE at 43f5add

(a) Scanner config. Only paths change, and no regex is broader:

  • The private_key entry moves to configure_gcp_store_test.go, which holds the fixture at :21.
  • The account-ID path list names 4 files, all containing matches; the removed files have none.
  • The {Account: ...} entry moves to multi_service_account_names_test.go.
  • The detect-private-key exclude adds only configure_gcp_store_test.go, which holds the dummy PEM.

The git-secrets script reports 44 PASS. pre-commit run detect-private-key --all-files passes, and git secrets --scan on the 58 changed files finds no hits.

(b) Sizes. All 50 commits are at most 398 lines. No cmd/*_test.go is over 500 lines; the largest is 494.

(c) Naming. Files follow <area>_<topic>_test.go and group cohesive tests. Cosmetic: "comprehensive" in main_purchase_id_comprehensive_test.go says little.

@cristim

cristim commented Oct 20, 2026

Copy link
Copy Markdown
Member Author

Review U (independent, claude-cc-libs-rev-U): APPROVE at 43f5add

The pure move holds:

  1. Line multiset. The sorted, trimmed line multiset of cmd/*_test.go over main..head only gains the 319 package, import and paren lines of the 41 new files. No line is removed or altered.
  2. Declarations. 844 top-level declarations at both main and the head, identical.
  3. Two-step move. Exactly one TestGeneratePurchaseIDComprehensive, and no "Moved" test name.
  4. Setup code. TestMain and init() stay where they were. A few same-package helpers moved with their tests, which is harmless.
  5. Tests. The test count is 525 at both. go test -count=1 ./cmd/... and go vet ./... pass at the head.

@cristim

cristim commented Oct 20, 2026

Copy link
Copy Markdown
Member Author

Merge gate verdict (claude-cc-libs)

Every gate holds at head 43f5add:

  • Two independent reviews approve the reviewed head 43f5add. The branch was then updated from main, and the PR diff is byte-identical to the reviewed diff (compared mechanically).
  • CI is green on 43f5add, which is the reviewed change on top of current main.
  • 0 unresolved threads; MERGEABLE/CLEAN.

CodeRabbit is waived as a merge gate under the 2026-10-19 decision. Squash-merging.

@cristim
cristim merged commit 699fb4c into main Oct 20, 2026
12 checks passed
@cristim
cristim deleted the test/1536-split-test-files branch October 20, 2026 03:02
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.

chore(tests): split Go test files above the 500-line ceiling [cli part]

1 participant