Skip to content

test(database): the same guarantees in 5 fewer tests and 170 fewer lines - #405

Merged
PiquelChips merged 2 commits into
mainfrom
test/cleanup-database
Nov 6, 2026
Merged

PiquelChips merged 2 commits into
mainfrom
test/cleanup-database

Conversation

@PiquelChips

Copy link
Copy Markdown
Member

The test suite has grown large and repetitive. This is the database crate's part of a repo-wide cleanup: the same guarantees are tested with less code, and nothing that was covered goes uncovered.

  • The connection URL tests are one table that checks each URL's exact error, not just "it fails", plus the effective TLS mode and socket path of the accepted ones.
  • The two halves of "a purged account's handle" (in deletions and handles) are one test. It also checks something nothing did before: once an operator releases the handle, it can be reused.
  • The scratch-schema, migration and lock-wait code that several tests copied is four cfg(test) helpers next to test_pool. The audit-log import test now runs every later migration, so it reads today's schema rather than a hand-picked subset.
  • The "outlives the account" tails and the origin and timestamp checks are dropped where the purge test and the auth-service tests already cover them.

76 → 71 tests, 233 insertions, 403 deletions. No production code changes.

Proved by: all 71 database tests passing against a scratch cluster (--run-ignored all), clippy -D warnings, and the SQLx prepare check.

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

Note

Written by Claude Opus 5.5 in Claude Code and reviewed by GPT 6.1 Sol and Claude Opus 5.5 (via T3 Code)

🤖 Generated with Claude Code

- One table-driven transport test replaces five URL validation tests.
- The purged handle tests in deletions and handles become one test that
  goes from purge through release to reuse.
- Migration tests share Database::scratch_schema and apply_migrations;
  the audit import now migrates to the current schema.
- Lock-wait tests share Database::backend and wait_for_lock.
- Account deletion tails in the events and deliveries tests go, since
  the purge test covers them, and so does a timestamp round-trip.
@coderabbitai

coderabbitai Bot commented Nov 6, 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 57 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: d241bfa3-fa1d-4da5-b014-f45e33d882bd
Commits

Reviewing files that changed from the base of the PR and between 0777309 and 1794dee.

Files selected for processing: 9

  • crates/database/src/connection/mod.rs
  • crates/database/src/connection/tests.rs
  • crates/database/src/repositories/deletions/tests.rs
  • crates/database/src/repositories/deliveries/tests.rs
  • crates/database/src/repositories/events/tests.rs
  • crates/database/src/repositories/handles/tests.rs
  • crates/database/src/repositories/oidc/tests.rs
  • crates/database/src/repositories/tokens/tests.rs
  • crates/database/tests/security.rs
  • 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 self-assigned this Nov 6, 2026
@PiquelChips PiquelChips added the tests Tests label Nov 6, 2026
@PiquelChips PiquelChips added this to the v0.1 milestone Nov 6, 2026
@github-project-automation github-project-automation Bot moved this to Needs Triage in sourceorigin.dev Nov 6, 2026
@PiquelChips PiquelChips moved this from Needs Triage to In Progress in sourceorigin.dev Nov 6, 2026
@PiquelChips
PiquelChips added this pull request to the merge queue Nov 6, 2026
Merged via the queue into main with commit b7d1ef4 Nov 6, 2026
9 checks passed
@PiquelChips
PiquelChips deleted the test/cleanup-database branch November 6, 2026 23:37
@github-project-automation github-project-automation Bot moved this from In Progress to Done in sourceorigin.dev Nov 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tests Tests

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant