Skip to content

refactor(api): split client_test into per-domain modules (#1173) - #1179

Open
sdairs wants to merge 5 commits into
claude/1173-api-split-models-testsfrom
claude/1173-api-split-client-tests
Open

sdairs wants to merge 5 commits into
claude/1173-api-split-models-testsfrom
claude/1173-api-split-client-tests

Conversation

@sdairs

@sdairs sdairs commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Part of #1173 (4 of 6: tests/client_test.rs). Stacked on #1178.

Summary

This splits tests/client_test.rs (7.2k lines, 231 wiremock tests) into tests/client/, which is still one client_test binary. Behaviour and test names are unchanged. Each test moves to the module named after the src/client/ file that defines the Client method it calls.

File Lines Contents
main.rs 52 mod declarations and the shared wiremock helpers (ok_json, ok_empty, created_json, setup)
client.rs 417 19 tests: construction, bearer/basic auth, base URL, error handling, malformed responses, HTTP status codes, and the one cross-domain error test
activity.rs 89 4 tests
api_keys.rs 243 8 tests
backups.rs 607 19 tests: backups, snapshots, backup configuration, backup buckets
byoc.rs 465 12 tests
clickpipes.rs 634 21 tests: pipes, schema discovery, CDC scaling, reverse private endpoints, service context
clickstack.rs 1196 37 tests: alerts, saved searches, dashboards, sources, webhooks, roles
invitations.rs 98 4 tests
members.rs 109 4 tests
organizations.rs 661 22 tests: organizations, quotas, usage cost, Prometheus, credit balances, notifications
postgres.rs 648 20 tests: services, config, logs, Prometheus, backups
query_api_endpoints.rs 243 5 tests
saved_queries.rs 286 6 tests
services.rs 859 30 tests: services, scaling, endpoints, upgrade window, settings, profiles, replica-aware routing
udfs.rs 509 16 tests
whoami.rs 130 4 tests

There is no rbac.rs, because no client test calls an organization_role* method. The ClickStack role tests go in clickstack.rs. tests/run_query_test.rs is unchanged.

Every section divider survives once. A section whose tests now land in several modules keeps its divider in the module that gets its first test.

Commits

  1. Pure git mv of tests/client_test.rs → tests/client/main.rs (100%), plus a [[test]] name = "client_test" target so the binary keeps its name. Cargo does not infer a second client target.
  2. Moves only. A script checked that all 235 original items (tests and helpers, with their attributes and doc comments) appear exactly once and byte-identical across the new files. Everything else is use/mod lines, dividers and blank lines. Review it with git show --color-moved=dimmed-zebra.
  3. Classifier. Each tests/client/*.rs path maps to no live Cloud suite, like tests/client_test.rs, which stays mapped so diffs that name it remain classified. The fixture in scripts/tests/ is updated. The install classifier only inventories crates/clickhousectl.
  4. .git-blame-ignore-revs entry for commit 2. This SHA must be updated if the stack is rebased before merge.
  5. Docs. crates/clickhouse-cloud-api/AGENTS.md describes the tests/client/ layout. The README needs no change because it names only the unchanged --test client_test target.

Visibility widenings

None. The helpers stay private in main.rs, and the modules reach them with use crate::{...}.

Tests

  • Counts match before and after: 916 listed tests (887 passed, 29 ignored) across clickhouse-cloud-api and clickhouse-openapi-analyzer. client_test lists the same 231 names. Names match once module paths are stripped.
  • check-openapi-drift.py --dry-run output is identical before and after.
  • fmt, both clippy configurations, cargo clippy -p clickhousectl, the --no-default-features check, cargo check --workspace --all-features, the API and analyzer tests (spec_coverage_test and model_facade_test untouched) and the Python classifier tests all pass.

Merge with a merge commit, not a squash. The .git-blame-ignore-revs entry names this PR's move commit. A squash merge would leave it pointing at a commit that isn't on main, and git would silently ignore it.

🤖 Generated with Claude Code


Note

Low Risk
Test-only file moves and Cargo/docs metadata; no changes to the public API client implementation.

Overview
Reorganizes the offline wiremock client_test suite from one ~7k-line tests/client_test.rs into tests/client/, still a single binary named client_test. Cargo.toml adds an explicit [[test]] entry pointing at tests/client/main.rs so the target name stays stable when Cargo no longer auto-discovers a lone file.

main.rs declares one module per src/client/ domain (plus client.rs for auth, construction, and shared error handling) and keeps the shared helpers (setup, ok_json, ok_empty, created_json). Existing tests are moved into matching files without behavior or name changes; AGENTS.md documents where to add new client tests. .git-blame-ignore-revs records the bulk move commit for blame hygiene.

Reviewed by Cursor Bugbot for commit f8cc2a5. Bugbot is set up for automated code reviews on this repo. Configure here.

sdairs and others added 5 commits October 30, 2026 20:54
Pure rename so blame follows the file. An explicit [[test]] target keeps
the client_test name; cargo does not also infer a second `client` target
for the same path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tests/client/main.rs keeps the module declarations and the shared
wiremock helpers (ok_json, ok_empty, created_json, setup); each test
moves unchanged to the module named after the src/client/ file that
defines the Client method it calls. client.rs takes the construction,
authentication, base URL and error-handling tests, plus the one test
that spans several domains. Every section divider survives once; where
a section's tests now land in several modules, its divider stays with
the module that receives the section's first test. Still one test
binary.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each tests/client/*.rs module maps to no live Cloud suite, like
tests/client_test.rs did: the client_test binary is offline wiremock
coverage and none of the live integration targets include it. The old
path stays mapped so diffs that name it remain classified. The install
classifier inventories only crates/clickhousectl, so it needs no entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@sdairs sdairs added enhancement New feature or request client Affects the HTTP client rust Pull requests that update rust code labels Oct 30, 2026
@sdairs
sdairs requested a review from iskakaushik as a code owner October 30, 2026 19:57
@sdairs
sdairs added this pull request to stack #1153 October 30, 2026 19:57

This branch has not been deployed

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

Labels

client Affects the HTTP client enhancement New feature or request rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant