From da729a83451bb6cb23ab3b6de8e758486d7f1ae0 Mon Sep 17 00:00:00 2001 From: "B. Petersen" Date: Sat, 31 Oct 2020 14:06:17 +0100 Subject: [PATCH] fix outdated test the test just did not work on the last day of a month. --- src/dc_tools.rs | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/dc_tools.rs b/src/dc_tools.rs index e88fe3218..7c64e7c9d 100644 --- a/src/dc_tools.rs +++ b/src/dc_tools.rs @@ -1174,22 +1174,16 @@ mod tests { assert_eq!(msgs.len(), 1); // do not repeat the warning every day ... + // (we test that for the 2 subsequent days, this may be the next month, so the result should be 1 or 2 device message) maybe_warn_on_outdated( &t.ctx, timestamp_now + (365 + 1) * 24 * 60 * 60, get_provider_update_timestamp(), ) .await; - let chats = Chatlist::try_load(&t.ctx, 0, None, None).await.unwrap(); - assert_eq!(chats.len(), 1); - let device_chat_id = chats.get_chat_id(0); - let msgs = chat::get_chat_msgs(&t.ctx, device_chat_id, 0, None).await; - assert_eq!(msgs.len(), 1); - - // ... but every month maybe_warn_on_outdated( &t.ctx, - timestamp_now + (365 + 31) * 24 * 60 * 60, + timestamp_now + (365 + 2) * 24 * 60 * 60, get_provider_update_timestamp(), ) .await; @@ -1197,6 +1191,21 @@ mod tests { assert_eq!(chats.len(), 1); let device_chat_id = chats.get_chat_id(0); let msgs = chat::get_chat_msgs(&t.ctx, device_chat_id, 0, None).await; - assert_eq!(msgs.len(), 2); + let test_len = msgs.len(); + assert!(test_len == 1 || test_len == 2); + + // ... but every month + // (forward generous 33 days to avoid being in the same month as in the previous check) + maybe_warn_on_outdated( + &t.ctx, + timestamp_now + (365 + 33) * 24 * 60 * 60, + get_provider_update_timestamp(), + ) + .await; + let chats = Chatlist::try_load(&t.ctx, 0, None, None).await.unwrap(); + assert_eq!(chats.len(), 1); + let device_chat_id = chats.get_chat_id(0); + let msgs = chat::get_chat_msgs(&t.ctx, device_chat_id, 0, None).await; + assert_eq!(msgs.len(), test_len + 1); } }