fix formatting and most of the test

This commit is contained in:
Simon Laux
2022-10-31 19:32:01 +01:00
committed by link2xt
parent 1bd53de1f7
commit 3fcbc03759
3 changed files with 16 additions and 12 deletions

View File

@@ -2852,7 +2852,11 @@ pub unsafe extern "C" fn dc_chat_get_mailinglist_addr(chat: *mut dc_chat_t) -> *
return "".strdup(); return "".strdup();
} }
let ffi_chat = &*chat; let ffi_chat = &*chat;
ffi_chat.chat.get_mailinglist_addr().unwrap_or_default().strdup() ffi_chat
.chat
.get_mailinglist_addr()
.unwrap_or_default()
.strdup()
} }
#[no_mangle] #[no_mangle]

View File

@@ -2989,7 +2989,7 @@ mod tests {
assert!(chat.can_send(&t.ctx).await?); assert!(chat.can_send(&t.ctx).await?);
assert_eq!( assert_eq!(
chat.get_mailinglist_addr(), chat.get_mailinglist_addr(),
"reply+elernshsetushoyseshetihseusaferuhsedtisneu@reply.github.com" Some("reply+elernshsetushoyseshetihseusaferuhsedtisneu@reply.github.com")
); );
assert_eq!(chat.name, "deltachat/deltachat-core-rust"); assert_eq!(chat.name, "deltachat/deltachat-core-rust");
assert_eq!(chat::get_chat_contacts(&t.ctx, chat_id).await?.len(), 1); assert_eq!(chat::get_chat_contacts(&t.ctx, chat_id).await?.len(), 1);
@@ -2998,7 +2998,7 @@ mod tests {
let chat = chat::Chat::load_from_db(&t.ctx, chat_id).await?; let chat = chat::Chat::load_from_db(&t.ctx, chat_id).await?;
assert!(!chat.can_send(&t.ctx).await?); assert!(!chat.can_send(&t.ctx).await?);
assert_eq!(chat.get_mailinglist_addr(), ""); assert_eq!(chat.get_mailinglist_addr(), None);
let chats = Chatlist::try_load(&t.ctx, 0, None, None).await?; let chats = Chatlist::try_load(&t.ctx, 0, None, None).await?;
assert_eq!(chats.len(), 1); assert_eq!(chats.len(), 1);
@@ -3057,7 +3057,7 @@ mod tests {
let chat = Chat::load_from_db(&t.ctx, chat_id).await.unwrap(); let chat = Chat::load_from_db(&t.ctx, chat_id).await.unwrap();
assert_eq!(chat.name, "delta-dev"); assert_eq!(chat.name, "delta-dev");
assert!(chat.can_send(&t).await?); assert!(chat.can_send(&t).await?);
assert_eq!(chat.get_mailinglist_addr(), "delta@codespeak.net"); assert_eq!(chat.get_mailinglist_addr(), Some("delta@codespeak.net"));
let msg = get_chat_msg(&t, chat_id, 0, 1).await; let msg = get_chat_msg(&t, chat_id, 0, 1).await;
let contact1 = Contact::load_from_db(&t.ctx, msg.from_id).await.unwrap(); let contact1 = Contact::load_from_db(&t.ctx, msg.from_id).await.unwrap();
@@ -3320,7 +3320,7 @@ Hello mailinglist!\r\n"
assert_eq!(chat.name, "ola"); assert_eq!(chat.name, "ola");
assert_eq!(chat::get_chat_msgs(&t, chat.id, 0).await.unwrap().len(), 1); assert_eq!(chat::get_chat_msgs(&t, chat.id, 0).await.unwrap().len(), 1);
assert!(!chat.can_send(&t).await?); assert!(!chat.can_send(&t).await?);
assert_eq!(chat.get_mailinglist_addr(), ""); assert_eq!(chat.get_mailinglist_addr(), None);
// receive another message with no sender name but the same address, // receive another message with no sender name but the same address,
// make sure this lands in the same chat // make sure this lands in the same chat
@@ -3373,7 +3373,7 @@ Hello mailinglist!\r\n"
); );
assert_eq!(chat.name, "Atlas Obscura"); assert_eq!(chat.name, "Atlas Obscura");
assert!(!chat.can_send(&t).await?); assert!(!chat.can_send(&t).await?);
assert_eq!(chat.get_mailinglist_addr(), ""); assert_eq!(chat.get_mailinglist_addr(), None);
Ok(()) Ok(())
} }
@@ -3402,7 +3402,7 @@ Hello mailinglist!\r\n"
assert_eq!(chat.grpid, "1234ABCD-123LMNO.mailing.dhl.de"); assert_eq!(chat.grpid, "1234ABCD-123LMNO.mailing.dhl.de");
assert_eq!(chat.name, "DHL Paket"); assert_eq!(chat.name, "DHL Paket");
assert!(!chat.can_send(&t).await?); assert!(!chat.can_send(&t).await?);
assert_eq!(chat.get_mailinglist_addr(), ""); assert_eq!(chat.get_mailinglist_addr(), None);
Ok(()) Ok(())
} }
@@ -3431,7 +3431,7 @@ Hello mailinglist!\r\n"
assert_eq!(chat.grpid, "dpdde.mxmail.service.dpd.de"); assert_eq!(chat.grpid, "dpdde.mxmail.service.dpd.de");
assert_eq!(chat.name, "DPD"); assert_eq!(chat.name, "DPD");
assert!(!chat.can_send(&t).await?); assert!(!chat.can_send(&t).await?);
assert_eq!(chat.get_mailinglist_addr(), ""); assert_eq!(chat.get_mailinglist_addr(), None);
Ok(()) Ok(())
} }
@@ -3452,7 +3452,7 @@ Hello mailinglist!\r\n"
assert_eq!(chat.grpid, "96540.xt.local"); assert_eq!(chat.grpid, "96540.xt.local");
assert_eq!(chat.name, "Microsoft Store"); assert_eq!(chat.name, "Microsoft Store");
assert!(!chat.can_send(&t).await?); assert!(!chat.can_send(&t).await?);
assert_eq!(chat.get_mailinglist_addr(), ""); assert_eq!(chat.get_mailinglist_addr(), None);
receive_imf( receive_imf(
&t, &t,
@@ -3465,7 +3465,7 @@ Hello mailinglist!\r\n"
assert_eq!(chat.grpid, "121231234.xt.local"); assert_eq!(chat.grpid, "121231234.xt.local");
assert_eq!(chat.name, "DER SPIEGEL Kundenservice"); assert_eq!(chat.name, "DER SPIEGEL Kundenservice");
assert!(!chat.can_send(&t).await?); assert!(!chat.can_send(&t).await?);
assert_eq!(chat.get_mailinglist_addr(), ""); assert_eq!(chat.get_mailinglist_addr(), None);
Ok(()) Ok(())
} }
@@ -3488,7 +3488,7 @@ Hello mailinglist!\r\n"
assert_eq!(chat.grpid, "51231231231231231231231232869f58.xing.com"); assert_eq!(chat.grpid, "51231231231231231231231232869f58.xing.com");
assert_eq!(chat.name, "xing.com"); assert_eq!(chat.name, "xing.com");
assert!(!chat.can_send(&t).await?); assert!(!chat.can_send(&t).await?);
assert_eq!(chat.get_mailinglist_addr(), ""); assert_eq!(chat.get_mailinglist_addr(), None);
Ok(()) Ok(())
} }