Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for scalatest eventually by implementing Retrying typeclass (1.x) #173

Merged
merged 1 commit into from
Jul 19, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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())),
)
}
}