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
scala-steward committed Nov 21, 2024
1 parent 673aa3b commit 75bbed7
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 15 deletions.
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

0 comments on commit 75bbed7

Please sign in to comment.