0

I have a project using kotest-assertions-arrow v1.0.3.
I have a code using shouldBeRight:

    obj.shouldBeRight { value ->
        assertThat(value.blahblahblah, equalTo(xyz))
    }

shouldBeRight is marked as deprecated in that version so I am trying to update it.
I am unable to find any indication on how I should to that (both on web on stackoverflow).
Trying to upgrade the lib version, I have an error saying that even the import of "io.kotest" is not available. I am using arrow-core v1.1.3 if it helps.
In addition to that, I can say that I found this page saying that either.shouldBeRight is still there in v1.3.3 so I am totally lost.
Can someone enlighten me on how to fix this situation?
Regards

Sixro
  • 402
  • 4
  • 16
  • Looking at the [repository](https://github.com/kotest/kotest-extensions-arrow) doesn't make me think `shouldBeRight` is deprecated. Could you post your build.gradle configuration or exactly which dependencies you are using? – LeoColman Apr 25 '23 at 17:23
  • Hi @LeoColman, I think a change in packages happened from the version I am using (v.1.0.3). The shouldBeRight used in the code are the ones that in v1.0.3 were present in io.kotest.assertions.arrow.either There is another one in io.kotest.assertions.arrow.core that is not deprecated, but has a different signature – Sixro Apr 26 '23 at 08:35
  • `shouldBeRight` does return the value tho, so maybe `obj.shouldBeRight().blahblahblah shouldBe xyz` does the same thing? – LeoColman Apr 26 '23 at 14:14

1 Answers1

0

The shouldBeRight that accepts a lambda is deprecated, because the shouldBeRight() without a lambda uses contracts to return you the value.

So instead of

e.shouldBeRight { r -> ... }

Simply do

val r = e.shouldBeRight()
r...

Or

e.shouldBeRight().apply {
  this....
}

Or as @leocolman says in the comments, you can just chain operations.

e.shouldBeRight().shouldBe....
sksamuel
  • 16,154
  • 8
  • 60
  • 108