Skip to content

Commit 0f5f59d

Browse files
committed
test: add TestContext.create_chat_id
1 parent df9e065 commit 0f5f59d

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

src/test_utils.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ impl TestContextManager {
186186
msg,
187187
to.name()
188188
));
189-
let chat = from.create_chat(to).await;
190-
let sent = from.send_text(chat.id, msg).await;
189+
let chat_id = from.create_chat_id(to).await;
190+
let sent = from.send_text(chat_id, msg).await;
191191
to.recv_msg(&sent).await
192192
}
193193

@@ -852,14 +852,23 @@ impl TestContext {
852852
Chat::load_from_db(&self.ctx, chat_id).await.unwrap()
853853
}
854854

855+
/// Creates or returns an existing 1:1 [`ChatId`] with another account.
856+
///
857+
/// This first creates a contact by exporting a vCard from the `other`
858+
/// and importing it into `self`,
859+
/// then creates a 1:1 chat with this contact.
860+
pub async fn create_chat_id(&self, other: &TestContext) -> ChatId {
861+
let contact_id = self.add_or_lookup_contact_id(other).await;
862+
ChatId::create_for_contact(self, contact_id).await.unwrap()
863+
}
864+
855865
/// Creates or returns an existing 1:1 [`Chat`] with another account.
856866
///
857867
/// This first creates a contact by exporting a vCard from the `other`
858868
/// and importing it into `self`,
859869
/// then creates a 1:1 chat with this contact.
860870
pub async fn create_chat(&self, other: &TestContext) -> Chat {
861-
let contact_id = self.add_or_lookup_contact_id(other).await;
862-
let chat_id = ChatId::create_for_contact(self, contact_id).await.unwrap();
871+
let chat_id = self.create_chat_id(other).await;
863872
Chat::load_from_db(self, chat_id).await.unwrap()
864873
}
865874

0 commit comments

Comments
 (0)