Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use assertk's key function for better error logs #1610

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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