From 2c1386fed80466e1f4fdb5614f100fce65a68148 Mon Sep 17 00:00:00 2001 From: Mojtaba Chenani Date: Wed, 18 Oct 2023 15:37:47 +0200 Subject: [PATCH] add tests --- .../persistence/dao/ConversationDAOTest.kt | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/persistence/src/commonTest/kotlin/com/wire/kalium/persistence/dao/ConversationDAOTest.kt b/persistence/src/commonTest/kotlin/com/wire/kalium/persistence/dao/ConversationDAOTest.kt index 96aa4f7a409..51f35a60bc1 100644 --- a/persistence/src/commonTest/kotlin/com/wire/kalium/persistence/dao/ConversationDAOTest.kt +++ b/persistence/src/commonTest/kotlin/com/wire/kalium/persistence/dao/ConversationDAOTest.kt @@ -1215,6 +1215,27 @@ class ConversationDAOTest : BaseDatabaseTest() { assertEquals(listOf(conversationEntity2.id), conversationDAO.getOneOnOneConversationIdsWithOtherUser(user1.id, protocol = ConversationEntity.Protocol.MLS)) } + @Test + fun givenMLSSelfConversationExists_whenGettingMLSSelfGroupId_thenShouldReturnGroupId() = runTest{ + // given + userDAO.upsertUser(user1) + conversationDAO.insertConversation(conversationEntity1.copy(type = ConversationEntity.Type.SELF)) + conversationDAO.insertConversation(conversationEntity2.copy(type = ConversationEntity.Type.SELF)) + + // then + assertEquals((conversationEntity2.protocolInfo as ConversationEntity.ProtocolInfo.MLS).groupId, conversationDAO.getMLSSelfConversationGroupId()) + } + + @Test + fun givenMLSSelfConversationDoesNotExist_whenGettingMLSSelfGroupId_thenShouldReturnNull() = runTest{ + // given + userDAO.upsertUser(user1) + conversationDAO.insertConversation(conversationEntity1.copy(type = ConversationEntity.Type.SELF)) + + // then + assertNull(conversationDAO.getMLSSelfConversationGroupId()) + } + private suspend fun insertTeamUserAndMember(team: TeamEntity, user: UserEntity, conversationId: QualifiedIDEntity) { teamDAO.insertTeam(team) userDAO.upsertUser(user)