Skip to content

refactor(tests): unit tests sit beside their module, and the largest test files split by flow - #335

Merged
PiquelChips merged 3 commits into
mainfrom
refactor/split-rust-tests
Nov 4, 2026
Merged

PiquelChips merged 3 commits into
mainfrom
refactor/split-rust-tests

Conversation

@PiquelChips

@PiquelChips PiquelChips commented Nov 4, 2026 •

Copy link
Copy Markdown
Member

Unit tests lived in two places: 21 files kept an inline mod tests { … } while 46 used a sibling tests.rs. Seven auth-service test files had also grown past 1,000 lines each (oidc's reached 2,500), so finding a flow's tests meant scrolling through everything else. This PR only moves tests. No test logic changes.

One placement. Inline blocks move to foo/tests.rs, so foo.rs becomes foo/mod.rs. This covers 14 files, including deletion/export, jobs, crypto::signing, ui::recovery and protocol::challenge.

The rule: inline blocks of 30 lines or fewer stay inline, since moving a test or two of a few asserts adds a file and a directory for nothing. Five stay under it: protocol/oauth.rs, protocol/claims.rs, ui/src/asset.rs, auth-service/src/assets.rs and telemetry/src/lib.rs. config.rs and oidc/authorize.rs are left alone because another thread is splitting them.

Split by flow. oidc, passkey, recovery, clients, federation, admin and security each get a tests/ directory. Shared fixtures go in tests/mod.rs and each flow gets its own file, for example oidc/tests/{tokens,logout,pushed,step_up,sdk_routes,…}.rs.

  • Helpers that only one flow uses move into that flow's file.
  • Fixtures other modules import keep their paths, such as admin::tests::{Account, Harness, …} and security::tests::assert_step_up_required.
  • Test paths gain a flow segment, and the docs that cite tests by path now use the new ones.
  • No #[expect(clippy::too_many_lines)] became unfulfilled: each one sits on a single test whose body didn't change.

Checks. For every split file, the old and new files contain the same lines once sorted, apart from imports and the new mod///! lines. just lint passes, and just db test runs 326 tests, all passing, plus the query-cache check.

The 30-line rule and the tests/ layout are now written down in docs/architecture/rust-conventions.md, and doc paths to the moved modules (jobs, ui::recovery) follow them.

Proved by just lint, just db test (326/326 pass) and a sorted-line comparison of every split file against the original.

Reviewed with review-loop: 1 round with 2× GPT 6.1 Sol and Claude Opus 5.5. Verdict: approved

Note

Written by Claude Opus 5.5 in Claude Code, with Claude Opus 5.5 subagents splitting the seven files, and reviewed by GPT 6.1 Sol and Claude Opus 5.5 (via T3 Code)

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 8 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 438613c8-313e-4c19-9cdb-131b8e4bc926
Commits

Reviewing files that changed from the base of the PR and between f74be6a and 0b75a5a.

Files selected for processing: 88
  • apps/auth-service/src/admin/overview/mod.rs
  • apps/auth-service/src/admin/overview/tests.rs
  • apps/auth-service/src/admin/tests.rs
  • apps/auth-service/src/admin/tests/accounts.rs
  • apps/auth-service/src/admin/tests/administrators.rs
  • apps/auth-service/src/admin/tests/deliveries.rs
  • apps/auth-service/src/admin/tests/handles.rs
  • apps/auth-service/src/admin/tests/invitations.rs
  • apps/auth-service/src/admin/tests/mod.rs
  • apps/auth-service/src/admin/tests/mutations.rs
  • apps/auth-service/src/admin/tests/reads.rs
  • apps/auth-service/src/admin/types/mod.rs
  • apps/auth-service/src/admin/types/tests.rs
  • apps/auth-service/src/clients/tests.rs
  • apps/auth-service/src/clients/tests/deletion.rs
  • apps/auth-service/src/clients/tests/mod.rs
  • apps/auth-service/src/clients/tests/origins.rs
  • apps/auth-service/src/clients/tests/owners.rs
  • apps/auth-service/src/clients/tests/registry.rs
  • apps/auth-service/src/deletion/export/mod.rs
  • apps/auth-service/src/deletion/export/tests.rs
  • apps/auth-service/src/federation/tests.rs
  • apps/auth-service/src/federation/tests/callback.rs
  • apps/auth-service/src/federation/tests/linking.rs
  • apps/auth-service/src/federation/tests/mod.rs
  • apps/auth-service/src/federation/tests/protocols.rs
  • apps/auth-service/src/federation/tests/sign_in.rs
  • apps/auth-service/src/federation/tests/signup.rs
  • apps/auth-service/src/jobs/mod.rs
  • apps/auth-service/src/jobs/tests.rs
  • apps/auth-service/src/oidc/tests.rs
  • apps/auth-service/src/oidc/tests/app_removal.rs
  • apps/auth-service/src/oidc/tests/authorization.rs
  • apps/auth-service/src/oidc/tests/logout.rs
  • apps/auth-service/src/oidc/tests/mod.rs
  • apps/auth-service/src/oidc/tests/protocol.rs
  • apps/auth-service/src/oidc/tests/pushed.rs
  • apps/auth-service/src/oidc/tests/sdk_client.rs
  • apps/auth-service/src/oidc/tests/sdk_routes.rs
  • apps/auth-service/src/oidc/tests/step_up.rs
  • apps/auth-service/src/oidc/tests/tokens.rs
  • apps/auth-service/src/passkey/tests.rs
  • apps/auth-service/src/passkey/tests/confirmation.rs
  • apps/auth-service/src/passkey/tests/counters.rs
  • apps/auth-service/src/passkey/tests/mod.rs
  • apps/auth-service/src/passkey/tests/registration.rs
  • apps/auth-service/src/passkey/tests/related_pages.rs
  • apps/auth-service/src/passkey/tests/sign_in.rs
  • apps/auth-service/src/passkey/tests/telemetry.rs
  • apps/auth-service/src/passkey/tests/validation.rs
  • apps/auth-service/src/recovery/tests.rs
  • apps/auth-service/src/recovery/tests/enroll.rs
  • apps/auth-service/src/recovery/tests/mod.rs
  • apps/auth-service/src/recovery/tests/probation.rs
  • apps/auth-service/src/recovery/tests/start.rs
  • apps/auth-service/src/recovery/tests/undo.rs
  • apps/auth-service/src/security/tests.rs
  • apps/auth-service/src/security/tests/caching.rs
  • apps/auth-service/src/security/tests/forwarding.rs
  • apps/auth-service/src/security/tests/mod.rs
  • apps/auth-service/src/security/tests/origins.rs
  • apps/auth-service/src/security/tests/rate_limits.rs
  • apps/auth-service/src/security/tests/sessions.rs
  • apps/web/src/site/mod.rs
  • apps/web/src/site/tests.rs
  • crates/common/src/email/mod.rs
  • crates/common/src/email/tests.rs
  • crates/common/src/protocol/challenge/mod.rs
  • crates/common/src/protocol/challenge/tests.rs
  • crates/common/src/protocol/step_up/mod.rs
  • crates/common/src/protocol/step_up/tests.rs
  • crates/crypto/src/sealing/mod.rs
  • crates/crypto/src/sealing/tests.rs
  • crates/crypto/src/signing/mod.rs
  • crates/crypto/src/signing/tests.rs
  • crates/database/src/repositories/passkeys/mod.rs
  • crates/database/src/repositories/passkeys/tests.rs
  • crates/telemetry/src/http/mod.rs
  • crates/telemetry/src/http/tests.rs
  • crates/ui/src/login/mod.rs
  • crates/ui/src/login/tests.rs
  • crates/ui/src/recovery/mod.rs
  • crates/ui/src/recovery/tests.rs
  • docs/architecture/federation-providers.md
  • docs/architecture/rust-conventions.md
  • docs/architecture/telemetry.md
  • docs/security/account-recovery.md
  • infra/README.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@PiquelChips
PiquelChips force-pushed the refactor/split-rust-tests branch 4 times, most recently from 95b77a9 to 04c9c92 Compare November 4, 2026 15:14
@PiquelChips PiquelChips self-assigned this Nov 4, 2026
@PiquelChips PiquelChips added refactor No behviour changes tests Tests labels Nov 4, 2026
@PiquelChips PiquelChips added this to the 0.1 milestone Nov 4, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in sourceorigin.dev Nov 4, 2026
@PiquelChips PiquelChips moved this from Needs Triage to In Progress in sourceorigin.dev Nov 4, 2026
@PiquelChips
PiquelChips force-pushed the refactor/split-rust-tests branch from 04c9c92 to 1078090 Compare November 4, 2026 16:47
PiquelChips and others added 3 commits November 4, 2026 17:57
… module

Inline test blocks over 30 lines move to foo/tests.rs, turning foo.rs into
foo/mod.rs. Smaller blocks stay inline, as do config.rs and
oidc/authorize.rs, which are being split elsewhere.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
oidc, passkey, recovery, clients, federation, admin and security tests
each become a tests/ directory: mod.rs holds the shared fixtures, and
each flow gets its own file. Test bodies are unchanged; doc references
follow the new paths.

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@PiquelChips
PiquelChips force-pushed the refactor/split-rust-tests branch from 1078090 to 0b75a5a Compare November 4, 2026 16:57
@PiquelChips
PiquelChips merged commit fef4422 into main Nov 4, 2026
9 checks passed
@PiquelChips
PiquelChips deleted the refactor/split-rust-tests branch November 4, 2026 17:07
@github-project-automation github-project-automation Bot moved this from In Progress to Done in sourceorigin.dev Nov 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactor No behviour changes tests Tests

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant