From 6484fae0cc60a3b27d8cb5bae9a05158b0f341ab Mon Sep 17 00:00:00 2001 From: Arpita-Jaiswal Date: Tue, 7 Nov 2023 20:46:10 +0530 Subject: [PATCH] Fix catch_panic_return_internal_server_error_response test --- fastn-core/src/catch_panic.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fastn-core/src/catch_panic.rs b/fastn-core/src/catch_panic.rs index 21985d23f6..e5fd83e6c3 100644 --- a/fastn-core/src/catch_panic.rs +++ b/fastn-core/src/catch_panic.rs @@ -84,12 +84,16 @@ where .map(move |res| match res { Ok(Ok(res)) => Ok(res), Ok(Err(svc_err)) => Err(svc_err), - Err(_panic_err) => Err(error::ErrorInternalServerError("500 Server Error")), + Err(_panic_err) => Err(error::ErrorInternalServerError( + INTERNAL_SERVER_ERROR_MESSAGE, + )), }) .boxed_local() } } +const INTERNAL_SERVER_ERROR_MESSAGE: &str = "500 Server Error"; + #[cfg(test)] mod tests { use actix_web::{ @@ -146,6 +150,6 @@ mod tests { let res = err.error_response(); assert_eq!(res.status(), StatusCode::INTERNAL_SERVER_ERROR); let body = to_bytes(res.into_body()).await.unwrap(); - assert!(body.is_empty()); + assert_eq!(body, INTERNAL_SERVER_ERROR_MESSAGE) } }