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

Update cats-effect to 3.5.5 #478

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions api/src/test/scala/slog4s/EffectTest.scala
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package slog4s

import cats.effect.syntax.all._
import cats.effect.{ConcurrentEffect, Sync, Timer}
import cats.effect.{ConcurrentEffect, Sync}
import cats.syntax.flatMap._
import org.scalactic.source
import org.scalatest.funspec.FixtureAnyFunSpec

import scala.concurrent.duration._
import cats.effect.Temporal

abstract class EffectTest[F[_]] extends FixtureAnyFunSpec {

protected def asEffect(fixtureParam: FixtureParam): ConcurrentEffect[F]
protected def asTimer(fixtureParam: FixtureParam): Timer[F]
protected def asTimer(fixtureParam: FixtureParam): Temporal[F]
protected def timeout: FiniteDuration = 10.seconds

def it_(
Expand Down
2 changes: 1 addition & 1 deletion api/src/test/scala/slog4s/MockClock.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package slog4s
import java.util.concurrent.TimeUnit

import cats.Monad
import cats.effect.concurrent.Ref
import cats.effect.{Clock, Sync}
import cats.syntax.flatMap._
import cats.syntax.functor._

import scala.concurrent.duration.Duration
import cats.effect.Ref

class MockClock[F[_]](val real: Ref[F, Long], val mono: Ref[F, Long])(implicit
F: Monad[F]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package slog4s.console.internal

import cats.effect.concurrent.Semaphore
import cats.effect.{Clock, Concurrent, Sync}
import cats.syntax.functor._
import slog4s.console.ConsoleConfig
import slog4s.shared.{AsContext, LoggingRuntime}
import slog4s.{Logger, LoggerFactory, LoggingContext, StructureBuilder}
import cats.effect.std.Semaphore

private[console] class LoggingRuntimeImpl[F[
_
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package slog4s.console.internal

import java.time.Instant

import cats.effect.concurrent.Semaphore
import slog4s.{Level, Location}
import cats.effect.std.Semaphore

private[console] class SyncFormatter[F[_], T](
semaphore: Semaphore[F],
Expand Down
9 changes: 5 additions & 4 deletions console/src/test/scala/slog4s/console/ConsoleConfigTest.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package slog4s.console

import cats.effect.{ConcurrentEffect, ContextShift, IO, Timer}
import cats.effect.{ConcurrentEffect, IO}
import cats.syntax.functor._
import cats.syntax.flatMap._
import org.scalactic.source.Position
Expand All @@ -9,19 +9,20 @@ import slog4s.{EffectTest, Level}
import slog4s.console.ConsoleConfigTest.Fixture

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

class ConsoleConfigTest extends EffectTest[IO] {
override protected def asEffect(
fixtureParam: FixtureParam
): ConcurrentEffect[IO] = fixtureParam.F

override protected def asTimer(fixtureParam: FixtureParam): Timer[IO] =
override protected def asTimer(fixtureParam: FixtureParam): Temporal[IO] =
fixtureParam.timer

override protected def withFixture(test: OneArgTest): Outcome = {
implicit val contextShift: ContextShift[IO] =
IO.contextShift(ExecutionContext.global)
implicit val timer: Timer[IO] = IO.timer(ExecutionContext.global)
implicit val timer: Temporal[IO] = IO.timer(ExecutionContext.global)
test(new Fixture[IO]())
}

Expand Down Expand Up @@ -57,7 +58,7 @@ object ConsoleConfigTest {
import org.scalatest.matchers.should.Matchers._
class Fixture[F[_]](implicit
val F: ConcurrentEffect[F],
val timer: Timer[F]
val timer: Temporal[F]
) {
def validateLevel(
fLevel: F[Level]
Expand Down
10 changes: 5 additions & 5 deletions console/src/test/scala/slog4s/console/ConsoleLoggerTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package slog4s.console

import java.io.{ByteArrayOutputStream, PrintStream}
import java.util.concurrent.{Executors, ThreadFactory}
import cats.effect.concurrent.Ref
import cats.effect.{ConcurrentEffect, ContextShift, IO, Resource, Sync, Timer}
import cats.effect.{ConcurrentEffect, IO, Resource, Sync}
import cats.syntax.all._
import slog4s.Location.Code
import slog4s.console.ConsoleLoggerTest.{Fixture, Output}
Expand All @@ -16,13 +15,14 @@ import slog4s.shared.{
import slog4s._

import scala.concurrent.ExecutionContext
import cats.effect.{ Ref, Temporal }

abstract class ConsoleLoggerTest[F[_]](format: Format) extends EffectTest[F] {
override protected def asEffect(
fixtureParam: FixtureParam
): ConcurrentEffect[F] = fixtureParam.F

override protected def asTimer(fixtureParam: FixtureParam): Timer[F] =
override protected def asTimer(fixtureParam: FixtureParam): Temporal[F] =
fixtureParam.T

override type FixtureParam = ConsoleLoggerTest.Fixture[F]
Expand All @@ -46,7 +46,7 @@ abstract class ConsoleLoggerTest[F[_]](format: Format) extends EffectTest[F] {
implicit val contextShift: ContextShift[IO] = IO.contextShift(ec)
implicit val F: Sync[IO] = ConcurrentEffect[IO]
implicit val mockClock: MockClock[IO] = MockClock.make[IO].unsafeRunSync()
implicit val timer: Timer[IO] = IO.timer(ec)
implicit val timer: Temporal[IO] = IO.timer(ec)
val contextRuntimeBuilder = new ContextRuntimeBuilder[IO] {
override def make[T](empty: T): IO[ContextRuntime[IO, T]] = {
Ref.of(empty).map { context =>
Expand Down Expand Up @@ -101,7 +101,7 @@ object ConsoleLoggerTest {
)(implicit
val F: ConcurrentEffect[F],
val C: MockClock[F],
val T: Timer[F]
val T: Temporal[F]
) {
val loggerName = "test-logger"
val logger = loggerFactory.make(loggerName)
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import sbt._

object Dependencies {
lazy val catsCore = "org.typelevel" %% "cats-core" % "2.12.0"
lazy val catsEffect = "org.typelevel" %% "cats-effect" % "2.5.5"
lazy val catsEffect = "org.typelevel" %% "cats-effect" % "3.5.5"
lazy val catsMtl = "org.typelevel" %% "cats-mtl-core" % "0.7.1"
lazy val circeCore = "io.circe" %% "circe-core" % "0.14.9"
lazy val circeLiteral =
Expand Down
12 changes: 6 additions & 6 deletions shared/src/test/scala/slog4s/shared/ContextTest.scala
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package slog4s.shared

import cats.effect.concurrent.Deferred
import cats.effect.syntax.all._
import cats.effect.{Bracket, ConcurrentEffect, Timer}
import cats.effect.ConcurrentEffect
import cats.syntax.flatMap._
import cats.syntax.functor._
import slog4s.EffectTest
import slog4s.shared.ContextTest.Fixture
import cats.effect.{ Deferred, MonadCancel, Temporal }

abstract class ContextTest[F[_]](runtimeName: String) extends EffectTest[F] {
override type FixtureParam = Fixture[F]
override protected def asEffect(
fixtureParam: Fixture[F]
): ConcurrentEffect[F] = fixtureParam.F
override protected def asTimer(fixtureParam: Fixture[F]): Timer[F] =
override protected def asTimer(fixtureParam: Fixture[F]): Temporal[F] =
fixtureParam.T

describe(s"$runtimeName-based context") {
Expand Down Expand Up @@ -95,8 +95,8 @@ abstract class ContextTest[F[_]](runtimeName: String) extends EffectTest[F] {
promise <- Deferred[F, Unit]
// promise used to indicate that a fiber has entered inside `guarantee`.
fiberStarted <- Deferred[F, Unit]
fiber <- Bracket[F, Throwable]
.guarantee(fiberCode(fiberStarted))(promise.complete(()))
fiber <- MonadCancel[F, Throwable]
.guarantee(fiberCode(fiberStarted), promise.complete(()))
.start
_ <- fiberStarted.get
_ <- fiber.cancel.start
Expand All @@ -110,7 +110,7 @@ abstract class ContextTest[F[_]](runtimeName: String) extends EffectTest[F] {
object ContextTest {
final class Fixture[F[_]](implicit
val F: ConcurrentEffect[F],
val T: Timer[F],
val T: Temporal[F],
val asContext: AsContext[F, Int],
val useContext: UseContext[F, Int]
)
Expand Down
Loading