Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
alexliesenfeld committed Oct 8, 2020
1 parent a3e7c0e commit b634dfb
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions src/api/mock.rs
Expand Up @@ -1665,24 +1665,24 @@ fn create_mismatch_output(idx: usize, mm: &Mismatch) -> String {
}

fn fail_with(closest_match: Option<ClosestMatch>) {
if closest_match.is_none() {
assert!(false, "No request has been received by the mock server.")
}
let closest_match = closest_match.unwrap();

let mut output = String::new();

output.push_str("At least one request has been received, but none exactly matched the mock specification.\n");
output.push_str(&format!(
"Here is a comparison with the most similar request (request number {}): \n\n",
closest_match.request_index + 1
));
match closest_match {
None => assert!(false, "No request has been received by the mock server."),
Some(closest_match) => {
let mut output = String::new();

output.push_str("At least one request has been received, but none exactly matched the mock specification.\n");
output.push_str(&format!(
"Here is a comparison with the most similar request (request number {}): \n\n",
closest_match.request_index + 1
));

for (idx, mm) in closest_match.mismatches.iter().enumerate() {
output.push_str(&create_mismatch_output(idx, &mm));
}

for (idx, mm) in closest_match.mismatches.iter().enumerate() {
output.push_str(&create_mismatch_output(idx, &mm));
assert!(false, output);
}
}

assert!(false, output);
}

#[cfg(test)]
Expand Down

0 comments on commit b634dfb

Please sign in to comment.