summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOwen Jacobson <owen@grimoire.ca>2024-09-25 23:35:31 -0400
committerOwen Jacobson <owen@grimoire.ca>2024-09-25 23:57:25 -0400
commitcce1ab45db0de5e912fa7eec8d8a2cfe9a314078 (patch)
treea5515c8487481cb5bf7082f8bd1431d76594c13a
parentfa21a7a397ae1f829e6e9c8f4a4bd30acda4372a (diff)
Retire `fixtures::error::expected!`.
I had no idea `std` included a `matches!` macro, and I feel we're better off using it.
-rw-r--r--src/channel/routes/test/on_create.rs7
-rw-r--r--src/channel/routes/test/on_send.rs7
-rw-r--r--src/login/routes/test/login.rs4
-rw-r--r--src/login/routes/test/logout.rs2
-rw-r--r--src/test/fixtures/error.rs14
-rw-r--r--src/test/fixtures/mod.rs1
6 files changed, 9 insertions, 26 deletions
diff --git a/src/channel/routes/test/on_create.rs b/src/channel/routes/test/on_create.rs
index df23deb..23885c0 100644
--- a/src/channel/routes/test/on_create.rs
+++ b/src/channel/routes/test/on_create.rs
@@ -50,9 +50,8 @@ async fn duplicate_name() {
// Verify the structure of the response
- fixtures::error::expected!(
+ assert!(matches!(
error,
- app::CreateError::DuplicateName(name),
- assert_eq!(request.name, name),
- );
+ app::CreateError::DuplicateName(name) if request.name == name
+ ));
}
diff --git a/src/channel/routes/test/on_send.rs b/src/channel/routes/test/on_send.rs
index 6690374..93a5480 100644
--- a/src/channel/routes/test/on_send.rs
+++ b/src/channel/routes/test/on_send.rs
@@ -141,9 +141,8 @@ async fn nonexistent_channel() {
// Verify the structure of the response
- fixtures::error::expected!(
+ assert!(matches!(
error,
- app::EventsError::ChannelNotFound(error_channel),
- assert_eq!(channel, error_channel)
- );
+ app::EventsError::ChannelNotFound(error_channel) if channel == error_channel
+ ));
}
diff --git a/src/login/routes/test/login.rs b/src/login/routes/test/login.rs
index 185239a..d92c01b 100644
--- a/src/login/routes/test/login.rs
+++ b/src/login/routes/test/login.rs
@@ -104,7 +104,7 @@ async fn authentication_failed() {
// Verify the return value's basic structure
- fixtures::error::expected!(error, app::LoginError::Rejected);
+ assert!(matches!(error, app::LoginError::Rejected));
}
#[tokio::test]
@@ -133,5 +133,5 @@ async fn token_expires() {
.await
.expect_err("validating an expired token");
- fixtures::error::expected!(error, app::ValidateError::InvalidToken);
+ assert!(matches!(error, app::ValidateError::InvalidToken));
}
diff --git a/src/login/routes/test/logout.rs b/src/login/routes/test/logout.rs
index 63b5727..4c09a73 100644
--- a/src/login/routes/test/logout.rs
+++ b/src/login/routes/test/logout.rs
@@ -84,5 +84,5 @@ async fn invalid_token() {
// Verify the return value's basic structure
- fixtures::error::expected!(error, app::ValidateError::InvalidToken);
+ assert!(matches!(error, app::ValidateError::InvalidToken));
}
diff --git a/src/test/fixtures/error.rs b/src/test/fixtures/error.rs
deleted file mode 100644
index 559afee..0000000
--- a/src/test/fixtures/error.rs
+++ /dev/null
@@ -1,14 +0,0 @@
-macro_rules! expected {
- ($expr:expr, $expect:pat $(,)?) => {
- $crate::test::fixtures::error::expected!($expr, $expect, ())
- };
-
- ($expr:expr, $expect:pat, $body:expr $(,)?) => {
- match $expr {
- $expect => $body,
- other => panic!("expected {}, found {other:#?}", stringify!($expect)),
- }
- };
-}
-
-pub(crate) use expected;
diff --git a/src/test/fixtures/mod.rs b/src/test/fixtures/mod.rs
index 05e3f3f..a42dba5 100644
--- a/src/test/fixtures/mod.rs
+++ b/src/test/fixtures/mod.rs
@@ -3,7 +3,6 @@ use chrono::{TimeDelta, Utc};
use crate::{app::App, clock::RequestedAt, repo::pool};
pub mod channel;
-pub mod error;
pub mod future;
pub mod identity;
pub mod login;