Expect 0 fails on matched()
fermanjj opened this issue · comments
If you create a mock with expect set to 0 and call .matched()
on the mock, it returns true without any receiving any requests which seems against the expected behaviour.
#[cfg(test)]
mod test {
#[test]
fn no_match() {
let m = mockito::mock("GET", "/").expect(0).create();
assert!(!m.matched()); // <--- this will panic
}
}
Quoting from the documentation:
Returns whether the expected amount of requests (defaults to 1) were performed.
So if you expect 0 requests then it's expected that matched()
returns true
. If you had anything but 0 requests to your mock, then matched()
should return false
.
BTW you can also replace assert!(m.matched())
with m.assert()
- it's the same.