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:
Jagoda Estera Ślązak
2026-08-10 13:36:09 +00:00
committed by GitHub
parent 97932fda07
commit fd8c56894a
36 changed files with 554 additions and 219 deletions
+3 -3
View File
@@ -2454,7 +2454,7 @@ async fn handle_post_message(
.context("expected Post-Message to have a message id")?;
let Some(msg_id) = message::rfc724_mid_exists(context, &rfc724_mid).await? else {
warn!(
info!(
context,
"handle_post_message: {rfc724_mid}: Database entry does not exist."
);
@@ -3465,13 +3465,13 @@ async fn group_changes_msgs(
) -> Result<Vec<(String, SystemMessage, Option<ContactId>)>> {
let mut group_changes_msgs: Vec<(String, SystemMessage, Option<ContactId>)> = Vec::new();
if !added_ids.is_empty() {
warn!(
info!(
context,
"Implicit addition of {added_ids:?} to chat {chat_id}."
);
}
if !removed_ids.is_empty() {
warn!(
info!(
context,
"Implicit removal of {removed_ids:?} from chat {chat_id}."
);