matthew graf
06/26/2020, 8:44 PMEither
type (Arrow)? The shouldBeRight()
matcher helps quite a bit but I found myself needing to use map
to check values within that object
val submittedPayment: Either<PaymentEventRepoError, Payment> = eventStore.getLatestPaymentForAccount(123)
submittedPayment.map { it.amount }.shouldBeRight(50.00.toBigDecimal())
submittedPayment.map { it.state }.shouldBeRight(PaymentState.PENDING)
Its not so bad but I’m wondering if anyone has a better patternsam
06/26/2020, 9:24 PMsam
06/26/2020, 9:24 PMmatthew graf
06/26/2020, 9:27 PMresponseList.shouldBeRight { it.size.shouldBe(1) }
Definitely feels more intuitive and reads a bit bettersam
06/26/2020, 9:30 PMsam
06/26/2020, 9:30 PMval right = either.shouldBeRight()
right.name shouldBe "sam"