add a test to make sure, contacts cannot be added/removed to one-to-one chats

This commit is contained in:
B. Petersen
2021-02-09 01:04:27 +01:00
committed by bjoern
parent 5922069b77
commit 6a4624be25

View File

@@ -3181,6 +3181,30 @@ mod tests {
assert_eq!(added, false);
}
#[async_std::test]
async fn test_add_remove_contact_for_single() {
let ctx = TestContext::new_alice().await;
let bob = Contact::create(&ctx, "", "bob@f.br").await.unwrap();
let chat_id = create_by_contact_id(&ctx, bob).await.unwrap();
let chat = Chat::load_from_db(&ctx, chat_id).await.unwrap();
assert_eq!(chat.typ, Chattype::Single);
assert_eq!(get_chat_contacts(&ctx, chat.id).await.len(), 1);
// adding or removing contacts from one-to-one-chats result in an error
let claire = Contact::create(&ctx, "", "claire@foo.de").await.unwrap();
let added = add_contact_to_chat_ex(&ctx, chat.id, claire, false).await;
assert!(added.is_err());
assert_eq!(get_chat_contacts(&ctx, chat.id).await.len(), 1);
let removed = remove_contact_from_chat(&ctx, chat.id, claire).await;
assert!(removed.is_err());
assert_eq!(get_chat_contacts(&ctx, chat.id).await.len(), 1);
let removed = remove_contact_from_chat(&ctx, chat.id, DC_CONTACT_ID_SELF).await;
assert!(removed.is_err());
assert_eq!(get_chat_contacts(&ctx, chat.id).await.len(), 1);
}
#[async_std::test]
async fn test_self_talk() {
let t = TestContext::new().await;