Skip to content

Commit

Permalink
test: display_chat(): Don't add day markers
Browse files Browse the repository at this point in the history
Otherwise golden_test_chat() fails when run around midnight.
  • Loading branch information
iequidoo committed Mar 26, 2024
1 parent 4781bd0 commit a2b28f1
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions src/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ use crate::chat::{
};
use crate::chatlist::Chatlist;
use crate::config::Config;
use crate::constants::DC_GCL_NO_SPECIALS;
use crate::constants::{Blocked, Chattype};
use crate::constants::{DC_GCL_NO_SPECIALS, DC_MSG_ID_DAYMARKER};
use crate::contact::{Contact, ContactAddress, ContactId, Modifier, Origin};
use crate::context::Context;
use crate::e2ee::EncryptHelper;
Expand Down Expand Up @@ -701,16 +701,16 @@ impl TestContext {
chat_id,
MessageListOptions {
info_only: false,
add_daymarker: true,
add_daymarker: false,
},
)
.await
.unwrap();
let msglist: Vec<MsgId> = msglist
.into_iter()
.map(|x| match x {
ChatItem::Message { msg_id } => msg_id,
ChatItem::DayMarker { .. } => MsgId::new(DC_MSG_ID_DAYMARKER),
.filter_map(|x| match x {
ChatItem::Message { msg_id } => Some(msg_id),
ChatItem::DayMarker { .. } => None,
})
.collect();

Expand Down Expand Up @@ -758,23 +758,17 @@ impl TestContext {

let mut lines_out = 0;
for msg_id in msglist {
if msg_id == MsgId::new(DC_MSG_ID_DAYMARKER) {
if msg_id.is_special() {
continue;
}
if lines_out == 0 {
writeln!(res,
"--------------------------------------------------------------------------------"
)
.unwrap();

lines_out += 1
} else if !msg_id.is_special() {
if lines_out == 0 {
writeln!(res,
"--------------------------------------------------------------------------------",
).unwrap();
lines_out += 1
}
let msg = Message::load_from_db(self, msg_id).await.unwrap();
write_msg(self, "", &msg, &mut res).await;
lines_out += 1
}
let msg = Message::load_from_db(self, msg_id).await.unwrap();
write_msg(self, "", &msg, &mut res).await;
}
if lines_out > 0 {
writeln!(
Expand Down

0 comments on commit a2b28f1

Please sign in to comment.