mirror of
https://github.com/chatmail/core.git
synced 2026-10-02 03:00:40 +03:00
test: Assert log warnings and errors (#8457)
Adds `assert_warn`, `assert_error` and `assert_warns_or_errors` methods to `TestContext`, that let us assert that a certain warning or error is logged during the test. Also asserts test logs should not contain any other errors or warnings. Adjusts tests accordingly. Signed-off-by: Jagoda Ślązak <jslazak@jslazak.com>
This commit is contained in:
@@ -143,9 +143,11 @@ mod tests {
|
||||
assert_eq!(t.get_last_error(), "");
|
||||
|
||||
error!(t, "foo-error");
|
||||
t.assert_error("foo-error").await;
|
||||
assert_eq!(t.get_last_error(), "foo-error");
|
||||
|
||||
warn!(t, "foo-warning");
|
||||
t.assert_warn("foo-warning").await;
|
||||
assert_eq!(t.get_last_error(), "foo-error");
|
||||
|
||||
info!(t, "foo-info");
|
||||
@@ -153,6 +155,8 @@ mod tests {
|
||||
|
||||
error!(t, "bar-error");
|
||||
error!(t, "baz-error");
|
||||
t.assert_error("bar-error").await;
|
||||
t.assert_error("baz-error").await;
|
||||
assert_eq!(t.get_last_error(), "baz-error");
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user