Skip to content

Commit

Permalink
Applied Scalafix rule(s) github:typelevel/cats-effect/v3_0_0?sha=v3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
typelevel-steward[bot] committed Nov 20, 2024
1 parent 590633a commit c6fe0ab
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@ package cats.effect.testing.minitest

import scala.concurrent.ExecutionContext

import cats.effect.{ContextShift, IO, Timer}
import cats.effect.IO
import minitest.api._
import cats.effect.Temporal


private[effect] abstract class BaseIOTestSuite[Ec <: ExecutionContext] extends AbstractTestSuite with Asserts {
Expand All @@ -29,7 +30,7 @@ private[effect] abstract class BaseIOTestSuite[Ec <: ExecutionContext] extends A
protected[effect] implicit def suiteEc: ExecutionContext = executionContext

implicit def ioContextShift: ContextShift[IO] = IO.contextShift(executionContext)
implicit def ioTimer: Timer[IO] = IO.timer(executionContext)
implicit def ioTimer: Temporal[IO] = IO.timer(executionContext)

protected[effect] def mkSpec(name: String, ec: Ec, io: => IO[Unit]): TestSpec[Unit, Unit]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ package cats.effect.testing.minitest

import scala.concurrent.ExecutionContext

import cats.effect.{ContextShift, IO, Timer}
import cats.effect.IO
import cats.effect.laws.util.TestContext
import scala.concurrent.duration._

import minitest.api.{DefaultExecutionContext, TestSpec}
import cats.effect.Temporal

abstract class DeterministicIOTestSuite extends BaseIOTestSuite[TestContext] {
override protected final def makeExecutionContext(): TestContext = TestContext()
Expand All @@ -32,7 +33,7 @@ abstract class DeterministicIOTestSuite extends BaseIOTestSuite[TestContext] {

override final implicit def ioContextShift: ContextShift[IO] =
executionContext.contextShift[IO](IO.ioEffect)
override final implicit def ioTimer: Timer[IO] = executionContext.timer[IO](IO.ioEffect)
override final implicit def ioTimer: Temporal[IO] = executionContext.timer[IO](IO.ioEffect)


override protected[effect] def mkSpec(name: String, ec: TestContext, io: => IO[Unit]): TestSpec[Unit, Unit] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,19 @@

package cats.effect.testing.scalatest

import cats.effect.{ContextShift, IO, Timer}
import cats.effect.IO
import org.scalactic.source.Position
import org.scalatest.AsyncTestSuite
import org.scalatest.enablers.Retrying
import org.scalatest.time.Span

import scala.concurrent.ExecutionContext
import cats.effect.Temporal

trait AsyncIOSpec extends AssertingSyntax with EffectTestSupport { asyncTestSuite: AsyncTestSuite =>
override val executionContext: ExecutionContext = ExecutionContext.global
implicit val ioContextShift: ContextShift[IO] = IO.contextShift(executionContext)
implicit val ioTimer: Timer[IO] = IO.timer(executionContext)
implicit val ioTimer: Temporal[IO] = IO.timer(executionContext)

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] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
package cats.effect.testing.scalatest

import cats.effect._
import cats.effect.concurrent.Ref
import org.scalatest.matchers.must.Matchers._
import org.scalatest.wordspec.FixtureAsyncWordSpec
import cats.effect.Ref

class CatsResourceSpecs extends FixtureAsyncWordSpec with AsyncIOSpec with CatsResourceIO[Ref[IO, Int]] {

Expand Down
5 changes: 3 additions & 2 deletions specs2/src/main/scala/cats/effect/testing/specs2/CatsIO.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@

package cats.effect.testing.specs2

import cats.effect.{ContextShift, IO, Timer}
import cats.effect.IO

import scala.concurrent.ExecutionContext
import cats.effect.Temporal

trait CatsIO extends CatsEffect {
implicit def executionContext: ExecutionContext = ExecutionContext.global
implicit def ioContextShift: ContextShift[IO] = IO.contextShift(executionContext)
implicit def ioTimer: Timer[IO] = IO.timer(executionContext)
implicit def ioTimer: Temporal[IO] = IO.timer(executionContext)
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
package cats.effect.testing.specs2

import cats.effect.{IO, Resource}
import cats.effect.concurrent.{Ref, Deferred}
import cats.implicits._
import org.specs2.mutable.Specification
import cats.effect.{ Deferred, Ref }

class CatsEffectSpecs extends Specification with CatsEffect {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package cats.effect.testing.specs2

import cats.effect._
import cats.effect.concurrent.Ref
import org.specs2.mutable.Specification
import cats.effect.Ref

class CatsResourceSpecs extends Specification with CatsResourceIO[Ref[IO, Int]] {
sequential
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@ package cats.effect.testing.utest
import scala.concurrent.{ExecutionContext, Future}
import scala.concurrent.duration._

import cats.effect.{ContextShift, IO, Timer}
import cats.effect.IO
import cats.effect.laws.util.TestContext
import utest.TestSuite
import cats.effect.Temporal


abstract class DeterministicIOTestSuite extends TestSuite {
protected val testContext: TestContext = TestContext()
protected def allowNonIOTests: Boolean = false

implicit def ioContextShift: ContextShift[IO] = testContext.contextShift(IO.ioEffect)
implicit def ioTimer: Timer[IO] = testContext.timer(IO.ioEffect)
implicit def ioTimer: Temporal[IO] = testContext.timer(IO.ioEffect)

override def utestWrap(path: Seq[String], runBody: => Future[Any])(implicit ec: ExecutionContext): Future[Any] = {
runBody.flatMap {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ package cats.effect.testing.utest
import scala.concurrent.duration._
import scala.concurrent.{ExecutionContext, Future}

import cats.effect.{ContextShift, IO, Timer}
import cats.effect.IO
import utest._
import cats.effect.Temporal


abstract class IOTestSuite extends TestSuite {
Expand All @@ -31,7 +32,7 @@ abstract class IOTestSuite extends TestSuite {
protected lazy val executionContext: ExecutionContext = makeExecutionContext()

implicit def ioContextShift: ContextShift[IO] = IO.contextShift(executionContext)
implicit def ioTimer: Timer[IO] = IO.timer(executionContext)
implicit def ioTimer: Temporal[IO] = IO.timer(executionContext)

override def utestWrap(path: Seq[String], runBody: => Future[Any])(implicit ec: ExecutionContext): Future[Any] = {
// Shadow the parameter EC with our EC
Expand Down

0 comments on commit c6fe0ab

Please sign in to comment.