Skip to content

Commit

Permalink
Add expect 0 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
lipanski committed Sep 27, 2023
1 parent 7514e38 commit b9007ea
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1382,6 +1382,26 @@ fn test_assert_panics_with_too_many_requests() {
mock.assert();
}

#[test]
fn test_expect_zero() {
let mut s = Server::new();
let mock = s.mock("GET", "/hello").expect(0).create();

mock.assert();
}

#[test]
#[should_panic(expected = "\n> Expected 0 request(s) to:\n\r\nGET /hello\r\n\n...but received 1\n")]
fn test_expect_zero_fail() {
let mut s = Server::new();
let host = s.host_with_port();
let mock = s.mock("GET", "/hello").expect(0).create();

request(&host, "GET /hello", "");

mock.assert();
}

#[test]
#[should_panic(
expected = "\n> Expected 1 request(s) to:\n\r\nGET /hello\r\n\n...but received 0\n\n> The last unmatched request was:\n\r\nGET /bye\r\n\n> Difference:\n\n\u{1b}[31mGET /hello\n\u{1b}[0m\u{1b}[32mGET\u{1b}[0m\u{1b}[32m \u{1b}[0m\u{1b}[42;30m/bye\u{1b}[0m\u{1b}[32m\n\u{1b}[0m\n\n"
Expand Down

0 comments on commit b9007ea

Please sign in to comment.