mirror of
https://github.com/chatmail/core.git
synced 2026-10-02 11:10:25 +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:
@@ -176,7 +176,7 @@ async fn test_search_contacts_from_group() -> Result<()> {
|
||||
let bob = &tcm.bob().await;
|
||||
let fiona = &tcm.fiona().await;
|
||||
|
||||
let alice_chat_id = chat::create_group(alice, "").await?;
|
||||
let alice_chat_id = chat::create_group(alice, "group").await?;
|
||||
let qr = get_securejoin_qr(alice, Some(alice_chat_id)).await?;
|
||||
let bob_chat_id = tcm.exec_securejoin_qr(bob, alice, &qr).await;
|
||||
tcm.exec_securejoin_qr(fiona, alice, &qr).await;
|
||||
@@ -238,6 +238,7 @@ async fn test_add_or_lookup() {
|
||||
"\nWonderland, Alice <alice@w.de>\n",
|
||||
);
|
||||
assert_eq!(Contact::add_address_book(&t, book).await.unwrap(), 4);
|
||||
t.assert_warn(r#"invalid address "+1234567890""#).await;
|
||||
|
||||
// check first added contact, this modifies authname because it is empty
|
||||
let (contact_id, sth_modified) = Contact::add_or_lookup(
|
||||
@@ -1095,6 +1096,11 @@ async fn test_was_seen_recently_event() -> Result<()> {
|
||||
.get_matching(|evt| matches!(evt, EventType::ContactsChanged { .. }))
|
||||
.await;
|
||||
}
|
||||
// this warning is only printed when `RecentlySeenLoop` is dropped,
|
||||
// so we can't assert it otherwise.
|
||||
drop(recently_seen_loop);
|
||||
bob.assert_warn("receiving from an empty and closed channel")
|
||||
.await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user