Skip to content

Commit

Permalink
Use assertk's key function for better error logs (#1610)
Browse files Browse the repository at this point in the history
  • Loading branch information
veyndan authored Oct 18, 2023
1 parent 8fa72b2 commit 79723b6
Showing 1 changed file with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import assertk.assertions.hasSize
import assertk.assertions.isEqualTo
import assertk.assertions.isInstanceOf
import assertk.assertions.isNotNull
import assertk.assertions.key
import assertk.assertions.single
import kotlin.test.Test
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
Expand Down Expand Up @@ -101,20 +103,24 @@ class StateSnapshotTest {
""".trimIndent(),
)
assertThat(deserialized.content).hasSize(stateSnapshot.content.size)
assertThat(deserialized.content["key1"]!![0])
assertThat(deserialized.content)
.key("key1")
.single()
.isNotNull()
.isInstanceOf<MutableState<*>>()
.corresponds(mutableStateOf(1), ::mutableStateCorrespondence)
assertThat(deserialized.content["key2"]).isEqualTo(listOf(1))
assertThat(deserialized.content["key3"]!![0])
assertThat(deserialized.content).key("key2").isEqualTo(listOf(1))
assertThat(deserialized.content)
.key("key3")
.single()
.isNotNull()
.isInstanceOf<MutableState<*>>()
.corresponds(mutableStateOf("str"), ::mutableStateCorrespondence)
assertThat(deserialized.content["key4"]).isEqualTo(listOf("str"))
assertThat(deserialized.content["key5"]).isEqualTo(listOf(null))
assertThat(deserialized.content["key6"]).isEqualTo(listOf(true))
assertThat(deserialized.content["key7"]).isEqualTo(listOf(1.5))
assertThat(deserialized.content["key8"]).isEqualTo(listOf(listOf(1, "str")))
assertThat(deserialized.content).key("key4").isEqualTo(listOf("str"))
assertThat(deserialized.content).key("key5").isEqualTo(listOf(null))
assertThat(deserialized.content).key("key6").isEqualTo(listOf(true))
assertThat(deserialized.content).key("key7").isEqualTo(listOf(1.5))
assertThat(deserialized.content).key("key8").isEqualTo(listOf(listOf(1, "str")))
}
}

Expand Down

0 comments on commit 79723b6

Please sign in to comment.