Skip to content

Commit c52e586

Browse files
committed
Implement tests for Backoff policy with maxDelay.
1 parent aede2cc commit c52e586

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/test/scala/PolicySpec.scala

+15
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,21 @@ class PolicySpec extends FunSpec with BeforeAndAfterAll {
116116
assert(took <= 110.millis === true,
117117
s"took more time than expected: $took")
118118
}
119+
120+
it ("should wait up to a max time each time") {
121+
implicit val success = Success[Int](_ == 2)
122+
val tries = forwardCountingFutureStream().iterator
123+
val policy = retry.Backoff(2, 30.millis, maxDelay = 50.millis)
124+
val took = time {
125+
val result = Await.result(policy(tries.next),
126+
80.millis + 20.millis)
127+
assert(success.predicate(result) === true, "predicate failed")
128+
}
129+
assert(took >= 80.millis === true,
130+
s"took less time than expected: $took")
131+
assert(took <= 100.millis === true,
132+
s"took more time than expected: $took")
133+
}
119134
}
120135

121136
describe("retry.When") {

0 commit comments

Comments
 (0)