File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -2293,4 +2293,43 @@ mod tests {
2293
2293
Ok ( ( ) )
2294
2294
} ) ;
2295
2295
}
2296
+
2297
+ #[ test]
2298
+ fn test_create_search_error_response ( ) {
2299
+ let response = create_search_error_response (
2300
+ "test_query" . to_string ( ) ,
2301
+ "relevance" . to_string ( ) ,
2302
+ "Service temporarily unavailable" . to_string ( ) ,
2303
+ ) ;
2304
+ assert_eq ! (
2305
+ response. title,
2306
+ "Search service is not currently available: Service temporarily unavailable"
2307
+ ) ;
2308
+ assert_eq ! ( response. status, http:: StatusCode :: SERVICE_UNAVAILABLE ) ;
2309
+ assert_eq ! ( response. release_type, ReleaseType :: Search ) ;
2310
+ }
2311
+
2312
+ #[ test]
2313
+ fn crates_io_search_returns_status_code_5xx ( ) {
2314
+ async_wrapper ( |env| async move {
2315
+ let mut crates_io = mockito:: Server :: new_async ( ) . await ;
2316
+ env. override_config ( |config| {
2317
+ config. registry_api_host = crates_io. url ( ) . parse ( ) . unwrap ( ) ;
2318
+ } ) ;
2319
+
2320
+ crates_io
2321
+ . mock ( "GET" , "/api/v1/crates" )
2322
+ . with_status ( 500 )
2323
+ . create_async ( )
2324
+ . await ;
2325
+
2326
+ let response = env
2327
+ . web_app ( )
2328
+ . await
2329
+ . get ( "/releases/search?query=anything_goes_here" )
2330
+ . await ?;
2331
+ assert_eq ! ( response. status( ) , 503 ) ;
2332
+ Ok ( ( ) )
2333
+ } )
2334
+ }
2296
2335
}
You can’t perform that action at this time.
0 commit comments