chore: fix the new clippy lint in tests

Draft
FE
9d ago
+11-11

What fails

The Lint job fails on every open PR, for example #119. Clippy reports 11 errors in old tests in src/emails.rs, src/events.rs and src/templates.rs.

Why

Rust 1.99.0 adds the clippy::assert_is_empty lint. The lint rejects assert!(x.is_empty()) and assert!(!x.is_empty()). CI uses the latest stable toolchain and runs clippy with -Dwarnings, so each warning is an error.

What changed

  • Each flagged assert!(x.is_empty()) is now assert_eq! against an empty value. Each assert!(!x.is_empty()) is now assert_ne!.
  • For Vec fields, the empty value is Vec::<T>::new(). Clippy suggests [] as [T; 0], but the crate denies trivial_casts, so that form does not compile.
  • For the url string, the empty value is "", as clippy suggests.

The assertions check the same conditions as before. Only test code changes, so there is no version bump.

Verification

  • cargo clippy --all-targets -- -Dwarnings passes for the async, rustls-tls and blocking configurations, with clippy 0.1.99.
  • cargo fmt --check and cargo build pass.
  • The offline tests that changed pass. The live share_email test needs RESEND_API_KEY and runs in CI.

This unblocks the Lint check on open PRs such as #119.


Summary by cubic

Fixes the failing Lint job on all open PRs by updating test assertions to satisfy the new clippy::assert_is_empty lint added in Rust 1.99.0.

  • Replaces assert!(x.is_empty()) with assert_eq! and assert!(!x.is_empty()) with assert_ne! in test code in src/emails.rs, src/events.rs, and src/templates.rs.
  • Uses Vec::<T>::new() as the empty value instead of [] as [T; 0], which the crate cannot compile because it denies trivial_casts.
  • Only test code changes, so there is no version bump.