Skip to content

Commit

Permalink
Merge pull request #173 from skennedy/feat/retrying-support-1.x
Browse files Browse the repository at this point in the history
Add support for scalatest eventually by implementing Retrying typeclass (1.x)
  • Loading branch information
djspiewak authored Jul 19, 2021
2 parents c8dac77 + e65f884 commit 30aeb34
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,12 @@

package cats.effect.testing.scalatest

import cats.effect.IO
import cats.effect.unsafe.{IORuntime, IORuntimeConfig}
import org.scalactic.source.Position
import org.scalatest.AsyncTestSuite
import org.scalatest.enablers.Retrying
import org.scalatest.time.Span

trait AsyncIOSpec extends AssertingSyntax with EffectTestSupport { asyncTestSuite: AsyncTestSuite =>

Expand All @@ -26,4 +30,11 @@ trait AsyncIOSpec extends AssertingSyntax with EffectTestSupport { asyncTestSuit

IORuntime(executionContext, executionContext, scheduler, sd, IORuntimeConfig())
}

implicit def ioRetrying[T]: Retrying[IO[T]] = new Retrying[IO[T]] {
override def retry(timeout: Span, interval: Span, pos: Position)(fun: => IO[T]): IO[T] =
IO.fromFuture(
IO(Retrying.retryingNatureOfFutureT[T](executionContext).retry(timeout, interval, pos)(fun.unsafeToFuture())),
)
}
}

0 comments on commit 30aeb34

Please sign in to comment.