Skip to content
Closed
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
17 changes: 17 additions & 0 deletions core/src/test/scala/ox/resilience/ImmediateRetryTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -210,4 +210,21 @@ class ImmediateRetryTest extends AnyFlatSpec with EitherValues with TryValues wi
result.value shouldBe message
counter shouldBe 6

it should "not pay exceptionCost if Left error is going to be retried and shouldPayPenaltyCost returns false" in:
// given
var counter = 0
val errorMessage = "boom"

def f: Either[String, Int] =
counter += 1
Left(errorMessage)

val adaptive = AdaptiveRetry(TokenBucket(2), 1, 1)
// when
val result = adaptive.retryEither(Schedule.immediate.maxRetries(5), (_: Either[String, Int]) => false)(f)

// then
result.left.value shouldBe errorMessage
counter shouldBe 6

end ImmediateRetryTest
Loading