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-laws to 3.5.5 #542

Closed
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
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ ThisBuild / sonatypeRepository := "https://s01.oss.sonatype.org/service/local"
val Versions = new {
val catsCore = "2.8.0"
val catsEffect = "3.3.14"
val catsEffect2 = "2.5.5"
val catsEffect2 = "3.5.5"
val circe = "0.14.6"
val jsoniter = "2.30.7"
val monix = "3.4.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import cats.Monad
import cats.data.OptionT
import cats.effect.Clock
import cats.effect.Concurrent
import cats.effect.concurrent.Semaphore
import cats.syntax.all._
import org.polyvariant.sttp.oauth2.cache.ExpiringCache
import org.polyvariant.sttp.oauth2.cache.ce2.CachingAccessTokenProvider.TokenWithExpirationTime
Expand All @@ -15,6 +14,7 @@ import org.polyvariant.sttp.oauth2.Secret

import java.time.Instant
import scala.concurrent.duration.Duration
import cats.effect.std.Semaphore

final class CachingAccessTokenProvider[F[_]: Monad: Clock](
delegate: AccessTokenProvider[F],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ package org.polyvariant.sttp.oauth2.cache.ce2

import cats.Monad
import cats.data.OptionT
import cats.effect.concurrent.Ref
import cats.effect.Clock
import cats.effect.Sync
import cats.implicits._
import org.polyvariant.sttp.oauth2.cache.ExpiringCache
import org.polyvariant.sttp.oauth2.cache.ce2.CatsRefExpiringCache.Entry

import java.time.Instant
import cats.effect.Ref

final class CatsRefExpiringCache[F[_]: Monad: Clock, K, V] private (ref: Ref[F, Map[K, Entry[V]]]) extends ExpiringCache[F, K, V] {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package org.polyvariant.sttp.oauth2.cache.ce2

import cats.FlatMap
import cats.effect.ContextShift
import cats.effect.IO
import cats.effect.Timer
import cats.effect.concurrent.Ref
import cats.syntax.all._
import org.polyvariant.sttp.oauth2.ClientCredentialsToken.AccessTokenResponse
import org.polyvariant.sttp.oauth2.cache.ExpiringCache
Expand All @@ -19,11 +16,12 @@ import org.scalatest.wordspec.AnyWordSpec
import java.time.Instant
import scala.concurrent.ExecutionContext
import scala.concurrent.duration._
import cats.effect.{ Ref, Temporal }

class CachingAccessTokenProviderParallelSpec extends AnyWordSpec with Matchers {
private val ec: ExecutionContext = ExecutionContext.global
implicit lazy val cs: ContextShift[IO] = IO.contextShift(ec)
implicit val clock: Timer[IO] = IO.timer(ec)
implicit val clock: Temporal[IO] = IO.timer(ec)

private val testScope: Option[Scope] = Scope.of("test-scope")
private val token = AccessTokenResponse(Secret("secret"), None, 10.seconds, testScope)
Expand Down Expand Up @@ -64,7 +62,7 @@ class CachingAccessTokenProviderParallelSpec extends AnyWordSpec with Matchers {
override def get(key: K): F[Option[V]] = delegate.get(key)

override def put(key: K, value: V, expirationTime: Instant): F[Unit] =
Timer[F].sleep(sleepDuration) *> delegate.put(key, value, expirationTime)
Temporal[F].sleep(sleepDuration) *> delegate.put(key, value, expirationTime)

override def remove(key: K): F[Unit] = delegate.remove(key)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
package org.polyvariant.sttp.oauth2.cache.ce2

import cats.effect.ContextShift
import cats.effect.IO
import cats.effect.Timer
import cats.effect.concurrent.Ref
import cats.effect.laws.util.TestContext
import org.polyvariant.sttp.oauth2.ClientCredentialsToken.AccessTokenResponse
import org.polyvariant.sttp.oauth2.Secret
Expand All @@ -15,11 +12,12 @@ import org.scalatest.Assertion

import scala.concurrent.duration._
import org.polyvariant.sttp.oauth2.AccessTokenProvider
import cats.effect.{ Ref, Temporal }

class CachingAccessTokenProviderSpec extends AnyWordSpec with Matchers {
implicit lazy val testContext: TestContext = TestContext.apply()
implicit lazy val cs: ContextShift[IO] = IO.contextShift(testContext)
implicit lazy val ioTimer: Timer[IO] = testContext.timer[IO]
implicit lazy val ioTimer: Temporal[IO] = testContext.timer[IO]

private val testScope: Option[Scope] = Scope.of("test-scope")
private val token = AccessTokenResponse(Secret("secret"), None, 10.seconds, testScope)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package org.polyvariant.sttp.oauth2.cache.ce2

import cats.effect.Clock
import cats.effect.ContextShift
import cats.effect.IO
import cats.effect.Timer
import cats.effect.laws.util.TestContext
import org.scalatest.matchers.should.Matchers
import org.scalatest.wordspec.AnyWordSpec
import scala.concurrent.duration._
import cats.effect.Temporal

class CatsRefExpiringCacheSpec extends AnyWordSpec with Matchers {
implicit lazy val testContext: TestContext = TestContext.apply()
implicit lazy val cs: ContextShift[IO] = IO.contextShift(testContext)
implicit lazy val ioTimer: Timer[IO] = testContext.timer[IO]
implicit lazy val ioTimer: Temporal[IO] = testContext.timer[IO]

private val someKey = "key"
private val someValue = 1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package org.polyvariant.sttp.oauth2.cache.ce2

import cats.Functor
import cats.effect.concurrent.Ref
import cats.syntax.all._
import org.polyvariant.sttp.oauth2.ClientCredentialsToken
import org.polyvariant.sttp.oauth2.Introspection
import org.polyvariant.sttp.oauth2.Secret
import org.polyvariant.sttp.oauth2.common.Scope
import org.polyvariant.sttp.oauth2.AccessTokenProvider
import cats.effect.Ref

trait TestAccessTokenProvider[F[_]] extends AccessTokenProvider[F] {
def setToken(scope: Option[Scope], token: ClientCredentialsToken.AccessTokenResponse): F[Unit]
Expand Down
Loading