Kev
07/13/2024, 9:16 AMInconsistent number of parameters in the descriptor and Java reflection object: 3 != 2
. Common code between the tests are:
data object MyError1
data object MyError2
@JvmInline
value class TestId(val id: String)
Failing code:
class Foo {
context(Raise<MyError2>)
suspend fun foo(): TestId {
return TestId("hello")
}
}
class Service(private val foo: Foo) {
context(Raise<MyError1>)
suspend fun test(): TestId {
return withError({ MyError1 }) {
foo.foo()
}
}
}
test("test 1") {
val foo = mockk<Foo>()
val service = Service(foo)
coEvery {
with(any<Raise<Any>>()) {
foo.foo()
}
}.coAnswers { TestId("hello") }
either {
service.test()
}.shouldBeRight()
}
Passing code (where instead of having a TestId
return type, I have a String
return type.
class Foo {
context(Raise<MyError2>)
suspend fun foo(): String {
return "hello"
}
}
class Service(private val foo: Foo) {
context(Raise<MyError1>)
suspend fun test(): String {
return withError({ MyError1 }) {
foo.foo()
}
}
}
test("test 1") {
val foo = mockk<Foo>()
val service = Service(foo)
coEvery {
with(any<Raise<Any>>()) {
foo.foo()
}
}.coAnswers { "hello" }
either {
service.test()
}.shouldBeRight()
}