Validate several ids in constructors (#336)
* Validate ids in constructors. * Remove redundant `.value` usage in string interpolation. * Make a distinction between `SessionId` and `UserId` in `TestData`.
This commit is contained in:
parent
f98fe8e52c
commit
e704870e3f
36 changed files with 193 additions and 199 deletions
|
|
@ -16,18 +16,17 @@
|
|||
|
||||
package io.element.android.tests.testutils
|
||||
|
||||
import com.google.common.truth.Truth.assertThat
|
||||
import org.junit.Assert.assertThrows
|
||||
|
||||
/**
|
||||
* Assert that the lambda throws on debug and returns null on release.
|
||||
* Assert that the lambda throws only on debug mode.
|
||||
*/
|
||||
fun assertNullOrThrow(lambda: () -> Any?) {
|
||||
fun assertThrowsInDebug(lambda: () -> Any?) {
|
||||
if (BuildConfig.DEBUG) {
|
||||
assertThrows(IllegalStateException::class.java) {
|
||||
lambda()
|
||||
}
|
||||
} else {
|
||||
assertThat(lambda()).isNull()
|
||||
lambda()
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue