mirror of
https://github.com/bitwarden/android.git
synced 2025-03-16 11:18:45 +03:00
Add logic to identify root cause of flakey test (#4056)
This commit is contained in:
parent
57d79cd51c
commit
79d2a00bf8
1 changed files with 20 additions and 1 deletions
|
@ -311,7 +311,7 @@ class CiphersServiceTest : BaseServiceTest() {
|
|||
)
|
||||
assertEquals(
|
||||
createMockAttachment(number = 1),
|
||||
result.getOrThrow(),
|
||||
result.testGetOrThrow(),
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -336,6 +336,25 @@ private fun setupMockUri(
|
|||
return mockUri
|
||||
}
|
||||
|
||||
/**
|
||||
* A helper method to attempt validate that the the value is being boxed and causing test to
|
||||
* inconsistently fail.
|
||||
*
|
||||
* This was modified from the code found here:
|
||||
* * https://github.com/mockk/mockk/issues/485#issuecomment-1973170516
|
||||
*/
|
||||
@Suppress("INVISIBLE_REFERENCE", "UNCHECKED_CAST")
|
||||
private fun <T> Result<T>.testGetOrThrow(): T =
|
||||
when (val unboxed: Any? = value) {
|
||||
is Result.Failure -> throw unboxed.exception
|
||||
!is Result<*> -> unboxed as T
|
||||
else -> {
|
||||
// This means the result is boxed, we could make this recursive to address the issue.
|
||||
println("Unboxed value = $unboxed")
|
||||
unboxed as T
|
||||
}
|
||||
}
|
||||
|
||||
private const val CREATE_ATTACHMENT_SUCCESS_JSON = """
|
||||
{
|
||||
"attachmentId":"mockAttachmentId-1",
|
||||
|
|
Loading…
Add table
Reference in a new issue