diff options
author | Toby Vincent <tobyv@tobyvin.dev> | 2024-04-03 16:43:41 -0500 |
---|---|---|
committer | Toby Vincent <tobyv@tobyvin.dev> | 2024-04-03 16:44:43 -0500 |
commit | 5fabfaafd6a560fc93029f19338fac090f0f5d85 (patch) | |
tree | 93c5991ed5d05f0eed0974e780f9b8fee60edfdc /src/routes/user.rs | |
parent | 9034c74cd36cdf3615dd80dc975500d235cebfcc (diff) |
refactor: clean up tests and remove unwraps
Diffstat (limited to 'src/routes/user.rs')
-rw-r--r-- | src/routes/user.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/routes/user.rs b/src/routes/user.rs index 71ed9a0..d23f66b 100644 --- a/src/routes/user.rs +++ b/src/routes/user.rs @@ -41,8 +41,10 @@ mod tests { const JWT_SECRET: &str = "test-jwt-secret-token"; const JWT_MAX_AGE: time::Duration = time::Duration::HOUR; + type TestResult<T = (), E = Box<dyn std::error::Error>> = std::result::Result<T, E>; + #[sqlx::test] - async fn test_user_not_found(pool: PgPool) -> Result<(), Error> { + async fn test_user_not_found(pool: PgPool) -> TestResult { let state = Arc::new(AppState { pool, jwt_secret: JWT_SECRET.to_string(), @@ -61,7 +63,7 @@ mod tests { .uri(format!("/api/user/{}", user.uuid)) .body(Body::empty())?; - let response = router.oneshot(request).await.unwrap(); + let response = router.oneshot(request).await?; assert_eq!(StatusCode::NOT_FOUND, response.status()); @@ -69,7 +71,7 @@ mod tests { } #[sqlx::test(fixtures(path = "../../fixtures", scripts("users")))] - async fn test_user_ok(pool: PgPool) -> Result<(), Error> { + async fn test_user_ok(pool: PgPool) -> TestResult { let state = Arc::new(AppState { pool, jwt_secret: JWT_SECRET.to_string(), @@ -88,7 +90,7 @@ mod tests { .uri(format!("/api/user/{}", user.uuid)) .body(Body::empty())?; - let response = router.oneshot(request).await.unwrap(); + let response = router.oneshot(request).await?; assert_eq!(StatusCode::OK, response.status()); |