Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@kciesielski
Last active June 30, 2023 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kciesielski/7b05788da8b308b6e6a9a7263650fafa to your computer and use it in GitHub Desktop.
Save kciesielski/7b05788da8b308b6e6a9a7263650fafa to your computer and use it in GitHub Desktop.
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
}
@drewfeelsblue
Copy link

drewfeelsblue commented Jun 30, 2023

hi, seems first line has duplicate should
it should "should

@kciesielski
Copy link
Author

Thanks, @drewfeelsblue, I updated the gist :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment