File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed
openai-client/src/test/scala/io/cequence/openaiscala Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -2,7 +2,7 @@ package io.cequence.openaiscala
2
2
3
3
import akka .actor .{ActorSystem , Scheduler }
4
4
import akka .testkit .TestKit
5
- import io .cequence .openaiscala .RetryHelpers .{RetrySettings , retry }
5
+ import io .cequence .openaiscala .RetryHelpers .{RetrySettings , delay , retry }
6
6
import org .mockito .scalatest .MockitoSugar
7
7
import org .scalatest .RecoverMethods ._
8
8
import org .scalatest .concurrent .ScalaFutures
@@ -86,6 +86,24 @@ class RetryHelpersSpec
86
86
}
87
87
}
88
88
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
+
89
107
}
90
108
91
109
implicit val scheduler : Scheduler = actorSystem.scheduler
You can’t perform that action at this time.
0 commit comments