Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mchenani committed Oct 18, 2023
1 parent 3945b26 commit 2c1386f
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2c1386f

Please sign in to comment.