File tree 1 file changed +11
-13
lines changed
wundergraph_cli/src/print_schema
1 file changed +11
-13
lines changed Original file line number Diff line number Diff line change @@ -328,24 +328,22 @@ mod tests {
328
328
client : & reqwest:: Client ,
329
329
listen_url : & str ,
330
330
body : & ' static str ,
331
- ) -> Result < ( ) , std:: string:: String > {
332
- let r = client
331
+ ) -> Result < ( ) , String > {
332
+ fn error_mapper < T : std:: fmt:: Debug > ( e : T ) -> String {
333
+ format ! ( "{:?}" , e)
334
+ }
335
+
336
+ let mut r = client
333
337
. post ( & format ! ( "http://{}/graphql" , listen_url) )
334
338
. body ( body)
335
339
. header (
336
340
reqwest:: header:: CONTENT_TYPE ,
337
341
reqwest:: header:: HeaderValue :: from_static ( "application/json" ) ,
338
342
)
339
- . send ( ) ;
340
- match r {
341
- Ok ( mut r) => match r. json :: < serde_json:: Value > ( ) {
342
- Ok ( r) => match std:: panic:: catch_unwind ( || insta:: assert_json_snapshot!( r) ) {
343
- Ok ( _) => Ok ( ( ) ) ,
344
- Err ( e) => Err ( format ! ( "{:?}" , e) ) ,
345
- } ,
346
- Err ( e) => Err ( format ! ( "{:?}" , e) ) ,
347
- } ,
348
- Err ( e) => Err ( format ! ( "{:?}" , e) ) ,
349
- }
343
+ . send ( )
344
+ . map_err ( error_mapper) ?;
345
+ let r = r. json :: < serde_json:: Value > ( ) . map_err ( error_mapper) ?;
346
+ std:: panic:: catch_unwind ( || insta:: assert_json_snapshot!( r) ) . map_err ( error_mapper) ?;
347
+ Ok ( ( ) )
350
348
}
351
349
}
You can’t perform that action at this time.
0 commit comments