Skip to content

refactor(api): split models_test into per-domain modules (#1173) - #1178

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

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

Conversation

@sdairs

@sdairs sdairs commented Oct 30, 2026 •

Copy link
Copy Markdown
Member

Part of #1173 (3 of 6: tests/models_test.rs). Stacked on #1177.

Summary

This splits crates/clickhouse-cloud-api/tests/models_test.rs (11.2k lines, 455 #[test] items) into a tests/models/ directory. It is still one test binary, and the target is still named models_test. No test changes.

File Lines Tests Contents
main.rs 35 0 mod declarations and the shared assert_unknown_variant_round_trips helper
activity.rs 99 5 Activity*
api_keys.rs 114 8 API keys
backups.rs 426 26 backups, backup buckets, snapshots
byoc.rs 468 22 BYOC infrastructure and config
clickpipes.rs 1952 70 ClickPipes sources, settings, reverse private endpoints, schema discovery
clickstack.rs 4803 170 ClickStack, including clickstack_enums
cross_domain.rs 328 8 union defaults, deprecated-field gating and tolerance tests that span several domains
organizations.rs 388 23 organizations, invitations, members, RBAC, quotas, notifications, Prometheus discovery
postgres.rs 929 39 Postgres services, config, slow queries, access lists
query_api_endpoints.rs 127 4 Query API endpoints
saved_queries.rs 83 3 saved queries
scim.rs 104 3 SCIM
services.rs 980 54 services, scaling, upgrade windows, settings, integer fields
shared.rs 197 11 ApiResponse envelope and pagination, shared request/response leaves, resource tags
udfs.rs 148 5 UDFs
whoami.rs 89 4 whoami

Each test moved unchanged to the module named after the src/models/ file whose types it exercises. The small invitations, members, rbac and quotas domains fold into organizations, and clickstack_enums folds into clickstack.

Commits

  1. Pure git mv of tests/models_test.rs to tests/models/main.rs (100% similarity), plus a [[test]] name = "models_test" target in Cargo.toml. Cargo does not also infer a second models target for the same path.
  2. Moves only. A script cut each top-level item (with its doc comments and attributes) out of the original. Every item now appears exactly once in the new files, byte-identical. The only other differences are the added mod/use lines and four dropped section-divider comments whose tests now sit in several modules. Review it with git show --color-moved=dimmed-zebra.
  3. Classifier. Each tests/models/*.rs file maps to no live Cloud suite, as models_test.rs did. The old path stays mapped so diffs that name it remain classified, and the classifier test fixture lists the new files. The install classifier only inventories crates/clickhousectl, so it needed no change.
  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/models/ layout. The README's --test models_test command is unchanged.

Visibility widenings

None. The shared helper stays a private function in main.rs, which its child modules can already see.

Tests

  • Counts match before and after: 916 tests listed for clickhouse-cloud-api and clickhouse-openapi-analyzer, 451 of them in models_test in each feature configuration. Test names match once module paths are stripped.
  • python3 scripts/check-openapi-drift.py --dry-run gives identical output before and after.
  • fmt, clippy for the library crates (--all-targets), both clickhousectl clippy configurations, the --no-default-features check, cargo check --workspace --all-features, cargo test -p clickhouse-cloud-api -p clickhouse-openapi-analyzer (with spec_coverage_test and model_facade_test unchanged) 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 layout and documentation; no library or runtime behavior changes.

Overview
Reorganizes the offline Cloud API model serde tests from a single ~11k-line models_test.rs into tests/models/, still compiled as one integration test binary named models_test.

Cargo.toml declares an explicit [[test]] target pointing at tests/models/main.rs so Cargo keeps the models_test name and does not auto-discover a duplicate. main.rs wires one module per src/models/ domain (small domains folded into parents, e.g. invitations/RBAC into organizations) plus cross_domain.rs for cross-cutting checks; shared assert_unknown_variant_round_trips stays in main.rs.

Test bodies are moved unchanged into domain files such as activity.rs, clickpipes.rs, postgres.rs, etc.—behavior and counts should match the monolith. AGENTS.md documents where to add new model tests. .git-blame-ignore-revs adds the bulk-move commit for cleaner blame history.

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

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tests/models/main.rs keeps the module declarations and the shared
assert_unknown_variant_round_trips helper; each test moves unchanged to
the module named after the src/models/ file whose types it exercises.
invitations, members, rbac and quotas fold into organizations,
clickstack_enums into clickstack, and tests that span several domains
go to cross_domain. Four section-divider comments whose tests now land
in several modules are dropped. Still one test binary.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each tests/models/*.rs module maps to no live Cloud suite, like
tests/models_test.rs did: the models_test binary is offline serde
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