mirror of
https://github.com/chatmail/core.git
synced 2026-05-01 20:36:31 +03:00
test: add TestContext.create_chat_id
This commit is contained in:
@@ -186,8 +186,8 @@ impl TestContextManager {
|
|||||||
msg,
|
msg,
|
||||||
to.name()
|
to.name()
|
||||||
));
|
));
|
||||||
let chat = from.create_chat(to).await;
|
let chat_id = from.create_chat_id(to).await;
|
||||||
let sent = from.send_text(chat.id, msg).await;
|
let sent = from.send_text(chat_id, msg).await;
|
||||||
to.recv_msg(&sent).await
|
to.recv_msg(&sent).await
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -852,14 +852,23 @@ impl TestContext {
|
|||||||
Chat::load_from_db(&self.ctx, chat_id).await.unwrap()
|
Chat::load_from_db(&self.ctx, chat_id).await.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Creates or returns an existing 1:1 [`ChatId`] with another account.
|
||||||
|
///
|
||||||
|
/// This first creates a contact by exporting a vCard from the `other`
|
||||||
|
/// and importing it into `self`,
|
||||||
|
/// then creates a 1:1 chat with this contact.
|
||||||
|
pub async fn create_chat_id(&self, other: &TestContext) -> ChatId {
|
||||||
|
let contact_id = self.add_or_lookup_contact_id(other).await;
|
||||||
|
ChatId::create_for_contact(self, contact_id).await.unwrap()
|
||||||
|
}
|
||||||
|
|
||||||
/// Creates or returns an existing 1:1 [`Chat`] with another account.
|
/// Creates or returns an existing 1:1 [`Chat`] with another account.
|
||||||
///
|
///
|
||||||
/// This first creates a contact by exporting a vCard from the `other`
|
/// This first creates a contact by exporting a vCard from the `other`
|
||||||
/// and importing it into `self`,
|
/// and importing it into `self`,
|
||||||
/// then creates a 1:1 chat with this contact.
|
/// then creates a 1:1 chat with this contact.
|
||||||
pub async fn create_chat(&self, other: &TestContext) -> Chat {
|
pub async fn create_chat(&self, other: &TestContext) -> Chat {
|
||||||
let contact_id = self.add_or_lookup_contact_id(other).await;
|
let chat_id = self.create_chat_id(other).await;
|
||||||
let chat_id = ChatId::create_for_contact(self, contact_id).await.unwrap();
|
|
||||||
Chat::load_from_db(self, chat_id).await.unwrap()
|
Chat::load_from_db(self, chat_id).await.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user