Skip to content

Commit 7174cb5

Browse files
committed
additional tests for delay()
1 parent a1f700d commit 7174cb5

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

openai-client/src/test/scala/io/cequence/openaiscala/RetryHelpersSpec.scala

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package io.cequence.openaiscala
22

33
import akka.actor.{ActorSystem, Scheduler}
44
import akka.testkit.TestKit
5-
import io.cequence.openaiscala.RetryHelpers.{RetrySettings, retry}
5+
import io.cequence.openaiscala.RetryHelpers.{RetrySettings, delay, retry}
66
import org.mockito.scalatest.MockitoSugar
77
import org.scalatest.RecoverMethods._
88
import org.scalatest.concurrent.ScalaFutures
@@ -86,6 +86,24 @@ class RetryHelpersSpec
8686
}
8787
}
8888

89+
"compute the correct delay when using constant interval" in {
90+
val interval = 10.seconds
91+
val settings = RetrySettings(interval)
92+
delay(1)(settings) shouldBe interval
93+
delay(5)(settings) shouldBe interval
94+
}
95+
96+
"compute the correct delay when using strictly positive base" in {
97+
val settings = RetrySettings(
98+
maxRetries = 5,
99+
delayOffset = 2.seconds,
100+
delayBase = 2
101+
)
102+
delay(1)(settings) shouldBe 4.seconds
103+
delay(2)(settings) shouldBe 6.seconds
104+
delay(3)(settings) shouldBe 10.seconds
105+
}
106+
89107
}
90108

91109
implicit val scheduler: Scheduler = actorSystem.scheduler

0 commit comments

Comments
 (0)