mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 03:09:04 +01:00
Add output of DeletionResult to deleteAllMessages call
This commit is contained in:
@@ -33,6 +33,7 @@ import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assertions.assertThrows
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.spongycastle.util.encoders.Base64
|
||||
import kotlin.random.Random
|
||||
|
||||
internal class MessagingControllerImplTest : ControllerTest() {
|
||||
|
||||
@@ -346,8 +347,10 @@ internal class MessagingControllerImplTest : ControllerTest() {
|
||||
|
||||
@Test
|
||||
fun testDeleteAllMessages() {
|
||||
val result = DeletionResult()
|
||||
every { ctx.pathParam("contactId") } returns "1"
|
||||
every { conversationManager.deleteAllMessages(ContactId(1)) } returns DeletionResult()
|
||||
every { conversationManager.deleteAllMessages(ContactId(1)) } returns result
|
||||
every { ctx.json(result.output()) } returns ctx
|
||||
controller.deleteAllMessages(ctx)
|
||||
}
|
||||
|
||||
@@ -368,6 +371,27 @@ internal class MessagingControllerImplTest : ControllerTest() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testOutputDeletionResult() {
|
||||
val result = DeletionResult()
|
||||
if (Random.nextBoolean()) result.addInvitationNotAllSelected()
|
||||
if (Random.nextBoolean()) result.addInvitationSessionInProgress()
|
||||
if (Random.nextBoolean()) result.addIntroductionNotAllSelected()
|
||||
if (Random.nextBoolean()) result.addIntroductionSessionInProgress()
|
||||
if (Random.nextBoolean()) result.addNotFullyDownloaded()
|
||||
val json = """
|
||||
{
|
||||
"allDeleted": ${result.allDeleted()},
|
||||
"hasIntroductionSessionInProgress": ${result.hasIntroductionSessionInProgress()},
|
||||
"hasInvitationSessionInProgress": ${result.hasInvitationSessionInProgress()},
|
||||
"hasNotAllIntroductionSelected": ${result.hasNotAllIntroductionSelected()},
|
||||
"hasNotAllInvitationSelected": ${result.hasNotAllInvitationSelected()},
|
||||
"hasNotFullyDownloaded": ${result.hasNotFullyDownloaded()}
|
||||
}
|
||||
"""
|
||||
assertJsonEquals(json, result.output())
|
||||
}
|
||||
|
||||
private fun expectGetContact() {
|
||||
every { ctx.pathParam("contactId") } returns contact.id.int.toString()
|
||||
every { contactManager.getContact(contact.id) } returns contact
|
||||
|
||||
Reference in New Issue
Block a user