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

refactor: migrate TraceSpec to kotlin-test #3253

Merged
merged 1 commit into from
Nov 8, 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 @@ -2,25 +2,26 @@ package arrow.core.raise

import arrow.core.right
import io.kotest.assertions.throwables.shouldThrow
import io.kotest.core.spec.style.StringSpec
import io.kotest.matchers.shouldBe
import io.kotest.property.Arb
import io.kotest.property.arbitrary.int
import io.kotest.property.arbitrary.string
import io.kotest.property.checkAll
import kotlin.test.Test
import kotlinx.coroutines.CompletableDeferred
import kotlinx.coroutines.test.runTest

@OptIn(ExperimentalTraceApi::class)
class TraceSpec : StringSpec({
"trace is empty when no errors" {
class TraceSpec {
@Test fun traceIsEmptyWhenNoErrors() = runTest {
checkAll(Arb.int()) { i ->
either<Nothing, Int> {
traced({ i }) { _,_ -> unreachable() }
} shouldBe i.right()
}
}

"trace is empty with exception" {
@Test fun traceIsEmptyWithException() = runTest {
checkAll(Arb.string()) { msg ->
val error = RuntimeException(msg)
shouldThrow<RuntimeException> {
Expand All @@ -31,7 +32,7 @@ class TraceSpec : StringSpec({
}
}

"nested tracing - identity" {
@Test fun nestedTracingIdentity() = runTest {
val inner = CompletableDeferred<String>()
ior(String::plus) {
traced({
Expand All @@ -43,4 +44,4 @@ class TraceSpec : StringSpec({
}
}
}
})
}
Loading