@@ -183,7 +183,7 @@ async fn test_files() {
183
183
let req_str = format ! ( "/{}?x=1" , test_file_path_string) ;
184
184
let resp = req_path_with_app_data ( & req_str, app_data. clone ( ) )
185
185
. await
186
- . unwrap_or_else ( |_ | panic ! ( "Failed to get response for {req_str}" ) ) ;
186
+ . unwrap_or_else ( |e | panic ! ( "Failed to get response for {req_str}: {e }" ) ) ;
187
187
let body = test:: read_body ( resp) . await ;
188
188
assert ! (
189
189
body. starts_with( b"<!DOCTYPE html>" ) ,
@@ -607,7 +607,7 @@ async fn test_official_website_documentation() {
607
607
let app_data = make_app_data_for_official_website ( ) . await ;
608
608
let resp = req_path_with_app_data ( "/component.sql?component=button" , app_data)
609
609
. await
610
- . unwrap ( ) ;
610
+ . unwrap_or_else ( |e| panic ! ( "Failed to get response for /component.sql?component=button: {e}" ) ) ;
611
611
assert_eq ! ( resp. status( ) , http:: StatusCode :: OK ) ;
612
612
let body = test:: read_body ( resp) . await ;
613
613
let body_str = String :: from_utf8 ( body. to_vec ( ) ) . unwrap ( ) ;
@@ -681,12 +681,18 @@ async fn srv_req_path_with_app_data(
681
681
. to_srv_request ( )
682
682
}
683
683
684
+ const REQ_TIMEOUT : std:: time:: Duration = std:: time:: Duration :: from_secs ( 3 ) ;
684
685
async fn req_path_with_app_data (
685
686
path : impl AsRef < str > ,
686
687
app_data : actix_web:: web:: Data < AppState > ,
687
- ) -> Result < actix_web:: dev:: ServiceResponse , actix_web:: Error > {
688
+ ) -> anyhow:: Result < actix_web:: dev:: ServiceResponse > {
689
+ let path = path. as_ref ( ) ;
688
690
let req = srv_req_path_with_app_data ( path, app_data) . await ;
689
- main_handler ( req) . await
691
+ let resp = tokio:: time:: timeout ( REQ_TIMEOUT , main_handler ( req) )
692
+ . await
693
+ . map_err ( |e| anyhow:: anyhow!( "Request to {path} timed out: {e}" ) ) ?
694
+ . map_err ( |e| anyhow:: anyhow!( "Request to {path} failed: {e}" ) ) ?;
695
+ Ok ( resp)
690
696
}
691
697
692
698
pub fn test_config ( ) -> AppConfig {
0 commit comments