From 5fabfaafd6a560fc93029f19338fac090f0f5d85 Mon Sep 17 00:00:00 2001 From: Toby Vincent Date: Wed, 3 Apr 2024 16:43:41 -0500 Subject: refactor: clean up tests and remove unwraps --- src/routes/user.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/routes/user.rs') 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> = std::result::Result; + #[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()); -- cgit v1.2.3-70-g09d2