Skip to content

Commit 27dda21

Browse files
p-alikweiznich
authored and
Alexei Pastuchov
committed
Update wundergraph_cli/src/print_schema/mod.rs
Co-authored-by: Georg Semmler <[email protected]>
1 parent 178a042 commit 27dda21

File tree

1 file changed

+10
-14
lines changed
  • wundergraph_cli/src/print_schema

1 file changed

+10
-14
lines changed

wundergraph_cli/src/print_schema/mod.rs

+10-14
Original file line numberDiff line numberDiff line change
@@ -328,24 +328,20 @@ mod tests {
328328
client: &reqwest::Client,
329329
listen_url: &str,
330330
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
333337
.post(&format!("http://{}/graphql", listen_url))
334338
.body(body)
335339
.header(
336340
reqwest::header::CONTENT_TYPE,
337341
reqwest::header::HeaderValue::from_static("application/json"),
338-
)
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-
}
342+
).send().map_err(error_mapper)?;
343+
let r = r.json::<serde_json::Value>().map_err(error_mapper)?;
344+
std::panic::catch_unwind(|| insta::assert_json_snapshot!(r)).map_err(error_mapper)?;
345+
Ok(())
350346
}
351347
}

0 commit comments

Comments
 (0)