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:
@@ -254,7 +254,7 @@ async fn test_message_stats() -> Result<()> {
|
||||
expected.get_mut(&Chattype::Single).unwrap().verified += 1;
|
||||
|
||||
check_stats(&send_and_read_stats(alice).await, &expected);
|
||||
|
||||
alice.assert_warn("Missing securejoin source").await;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -319,10 +319,12 @@ async fn test_stats_securejoin_sources() -> Result<()> {
|
||||
join_securejoin_with_ux_info(alice, &qr, Some(SecurejoinSource::InternalLink), None).await?;
|
||||
expected.internal_link += 1;
|
||||
check_stats(alice, &expected).await;
|
||||
alice.assert_warn("Missing securejoin source").await;
|
||||
|
||||
join_securejoin_with_ux_info(alice, &qr, Some(SecurejoinSource::ImageLoaded), None).await?;
|
||||
expected.image_loaded += 1;
|
||||
check_stats(alice, &expected).await;
|
||||
alice.assert_warn("Missing securejoin source").await;
|
||||
|
||||
join_securejoin_with_ux_info(alice, &qr, Some(SecurejoinSource::Scan), None).await?;
|
||||
expected.scan += 1;
|
||||
@@ -370,22 +372,27 @@ async fn test_stats_securejoin_uipaths() -> Result<()> {
|
||||
join_securejoin(alice, &qr).await?;
|
||||
expected.other += 1;
|
||||
check_stats(alice, &expected).await;
|
||||
alice.assert_warn("Missing securejoin source").await;
|
||||
|
||||
join_securejoin(alice, &qr).await?;
|
||||
expected.other += 1;
|
||||
check_stats(alice, &expected).await;
|
||||
alice.assert_warn("Missing securejoin source").await;
|
||||
|
||||
join_securejoin_with_ux_info(alice, &qr, None, Some(SecurejoinUiPath::NewContact)).await?;
|
||||
expected.new_contact += 1;
|
||||
check_stats(alice, &expected).await;
|
||||
alice.assert_warn("Missing securejoin source").await;
|
||||
|
||||
join_securejoin_with_ux_info(alice, &qr, None, Some(SecurejoinUiPath::NewContact)).await?;
|
||||
expected.new_contact += 1;
|
||||
check_stats(alice, &expected).await;
|
||||
alice.assert_warn("Missing securejoin source").await;
|
||||
|
||||
join_securejoin_with_ux_info(alice, &qr, None, Some(SecurejoinUiPath::QrIcon)).await?;
|
||||
expected.qr_icon += 1;
|
||||
check_stats(alice, &expected).await;
|
||||
alice.assert_warn("Missing securejoin source").await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -461,6 +468,13 @@ async fn test_stats_securejoin_invites() -> Result<()> {
|
||||
});
|
||||
check_stats(alice, &expected).await;
|
||||
|
||||
alice.assert_warn("Missing securejoin source").await;
|
||||
alice.assert_warn("Missing securejoin source").await;
|
||||
alice.assert_warn("Missing securejoin source").await;
|
||||
alice.assert_warn("Missing securejoin source").await;
|
||||
bob.assert_warn("missing key").await;
|
||||
bob.assert_warn("unencrypted message").await;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user