Last active
June 30, 2023 13:47
-
-
Save kciesielski/7b05788da8b308b6e6a9a7263650fafa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it should "succeed when it finishes shortly before the timeout" in { | |
// given | |
val slowService = new SlowService(responseTimes = List(2800.millis)) | |
val service = new TimeoutService(slowService) // 3s | |
// when | |
val result = service.run().unsafeToFuture() | |
ec.tick(TimeoutService.DefaultTimeout) // 3s forward in time! | |
// then | |
result.futureValue.value shouldBe (()) | |
} | |
it should "succeed after a few retries" in { | |
// given | |
val failingService = new FailingService(FailCount(2)) | |
val service = new RetryingService(failingService) | |
// when | |
val result = service.run().unsafeToFuture() | |
ec.tick(10.seconds) | |
// then | |
result.futureValue.value shouldBe (()) | |
failingService.accumulatedFailures shouldBe FailCount(2) | |
} | |
it should "fail due to exceeded retries on timeouts" in { | |
// given | |
val slowService = new SlowService(responseTimes = List.fill(6)(4.seconds)) | |
val timingOutService = new TimeoutService(slowService) | |
val retryingService = new RetryingService(timingOutService) | |
// when | |
val result = retryingService.run().unsafeToFuture() | |
ec.tick(30.seconds) | |
// then | |
result.failed.futureValue shouldBe a[ExpectedException] | |
slowService.attempts shouldBe 6 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
hi, seems first line has duplicate
should
it should "should