Skip to content

Commit

Permalink
cover comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mchenani committed Nov 16, 2023
1 parent ab5d8b4 commit f78170b
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ data class CryptoQualifiedClientId(
}

data class WireIdentity(
var clientId: String,
var handle: String,
var displayName: String,
var domain: String,
var certificate: String
val clientId: String,
val handle: String,
val displayName: String,
val domain: String,
val certificate: String
)

@Suppress("MagicNumber")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ data class DecryptedMessageBundle(
val identity: E2EIdentity?
)

data class E2EIdentity(var clientId: String, var handle: String, var displayName: String, var domain: String)
data class E2EIdentity(val clientId: String, val handle: String, val displayName: String, val domain: String)

@Suppress("TooManyFunctions", "LongParameterList")
interface MLSConversationRepository {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ class E2EIRepositoryImpl(

override suspend fun loadACMEDirectories(): Either<CoreFailure, AcmeDirectory> = userConfigRepository.getE2EISettings().flatMap {
wrapApiRequest {
// todo: remove after testing e2ei
val discoverUrl = "https://acme.elna.wire.link/acme/defaultteams"
acmeApi.getACMEDirectories(discoverUrl)
acmeApi.getACMEDirectories(TEMP_ACME_DISCOVER_URL)
}.flatMap { directories ->
e2EIClientProvider.getE2EIClient().flatMap { e2eiClient ->
wrapE2EIRequest {
Expand Down Expand Up @@ -207,4 +205,8 @@ class E2EIRepositoryImpl(
}
}

companion object{
// todo: remove after testing e2ei
const val TEMP_ACME_DISCOVER_URL = "https://acme.elna.wire.link/acme/defaultteams"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,51 @@ class EitherTest {

assertEquals(callCount, 0)
}

@Test
fun givenGetOrFailIsCalled_whenEitherIsRight_returnsRValue() {
val expected = "Expected"
val either = Either.Right(expected)
val result = either.getOrFail {
fail("Shouldn't be executed")
}
assertSame(result, expected)
}

@Test
fun givenGetOrFailIsCalled_whenEitherIsLeft_returnsUniValueAndRunFL() {
val expected = "Expected"
val either = Either.Left(expected)
val result = either.getOrFail {
assertSame(it, expected)
}
assertSame(result, Unit)
}

@Test
fun givenGetOrFailIsCalledInBlock_whenEitherIsLeft_innerReturnCalled() {
val expected = "Expected"
val either = Either.Left(expected)
val failReturn: String = run {
either.getOrFail {
assertSame(it, expected)
return@run it
}
fail("Shouldn't be executed")
}
assertSame(failReturn, expected)
}

@Test
fun givenGetOrFailIsCalledInBlock_whenEitherIsRight_innerReturnNotCalled() {
val expected = "Expected"
val either = Either.Right(expected)
val result: String = run {
val value = either.getOrFail {
fail("Shouldn't be executed")
}
return@run value
}
assertSame(result, expected)
}
}

0 comments on commit f78170b

Please sign in to comment.