Replace assert!(matches!(...)) with assert_matches!

Open Beginner friendly
#141 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
84/100
Issue type
Refactor
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
testing

Research direction

Start with the 31 listed call sites in the issue, replacing only assertion uses of matches!; leave the listed boolean-expression uses unchanged. Add use std::assert_matches; in each affected Rust file, preserving guards and custom messages. Check the multi-line assertion in tellus/src/persistence_tests.rs, the doc example in tellus/src/testing.rs, and the example in docs/persistence.md; done when all listed call sites use the new macro and the examples remain valid.

Written by the indexing model from the issue text.

Description

good first issue test

std::assert_matches! is stable on our pinned toolchain (1.99.0). On failure it prints the actual value, whereas assert!(matches!(...)) only reports "assertion failed". It takes guards (if ...) and a custom message like assert!, so every call site converts one to one; each file needs use std::assert_matches;, as the macro is not in the prelude.

Call sites on main (31):

  • tellus/src/actor_config.rs: 179, 183, 216
  • tellus/src/mailbox.rs: 258, 274, 291, 319, 320, 347, 377, 393, 394, 400, 477
  • tellus/src/quota.rs: 173, 232, 247, 265, 276, 309
  • tellus/src/persistence/versioned.rs: 188
  • tellus/src/persistence_tests.rs: 94, 145 (multi-line assert!( with a message)
  • tellus/tests/ask.rs: 58, 88, 105, 123 (with a guard), 161, 247
  • tellus/src/testing.rs: 230 (doc example, so it shows in the API docs)
  • docs/persistence.md: 253 (example)

Not in scope: matches! used as a boolean expression (tellus/src/mailbox.rs 71 and 81, tellus/tests/persistence.rs 135, tellus-persistence-postgres/src/lib.rs 264).

The unit-testing how-to tests, coming with the docs PR for the event-sourced tutorial, use assert_matches! already.

Dominant language
Rust
Stars
37
Forks
1
Avg merge
6h 36m
Merged PRs (30d)
123

Getting set up

  • Ships a Dockerfile or Docker Compose file
  • No pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from tellus-rs/tellus

All issues in tellus-rs/tellus

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.