Skip to content

Commit

Permalink
Update to cats-effect 3 (#365)
Browse files Browse the repository at this point in the history
  • Loading branch information
JesusMtnez authored May 20, 2021
1 parent 4e37c2a commit 22450ee
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 36 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,11 @@ libraryDependencies ++= Seq(
```

For more info visit [the microsite](https://davenverse.github.io/fuuid/)

## Versions

| fuuid | Scala 2.12 | Scala 2.13 | Scala 3 | Cats | CE | http4s | Doobie | Circe |
| :-----: | :--------: | :--------: | :-----: | :---: | :----: | :------: | :------: | :------: |
| `0.8.x` | Yes | Yes | Pending | `2.x` | `3.x` | `1.0.x` | `1.0.x` | `1.0.x` |
| `0.7.x` | Yes | Yes | Pending | `2.x` | `2.x` | `0.21.x` | `0.13.x` | `0.14.x` |
| `0.6.x` | Yes | Yes | Pending | `2.x` | `2.x` | `0.21.x` | `0.13.x` | `0.13.x` |
20 changes: 11 additions & 9 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,15 @@ lazy val docs = project
.dependsOn(coreJVM, http4s, doobie, circeJVM)

val catsV = "2.6.1" //https://github.com/typelevel/cats/releases
val catsEffectV = "2.5.1" //https://github.com/typelevel/cats-effect/releases
val catsEffectV = "3.1.1" //https://github.com/typelevel/cats-effect/releases
val specs2V = "4.11.0" //https://github.com/etorreborre/specs2/releases
val disciplineSpecs2V = "1.1.6"
val circeV = "0.14.0-M7" //https://github.com/circe/circe/releases
val http4sV = "0.21.23" //https://github.com/http4s/http4s/releases
val doobieV = "0.13.3" //https://github.com/tpolecat/doobie/releases
val http4sV = "1.0.0-M21" //https://github.com/http4s/http4s/releases
val doobieV = "1.0.0-M2" //https://github.com/tpolecat/doobie/releases
val scalaJavaTimeV = "2.3.0" // https://github.com/cquiroz/scala-java-time/releases
val testcontainersV = "0.39.4"
val catsEffectTestingV = "1.1.0"

lazy val contributors = Seq(
"ChristopherDavenport" -> "Christopher Davenport",
Expand All @@ -168,12 +169,13 @@ lazy val commonSettings = Seq(
addCompilerPlugin("org.typelevel" % "kind-projector" % "0.13.0" cross CrossVersion.full),
addCompilerPlugin("com.olegpy" %% "better-monadic-for" % "0.3.1"),
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.typelevel" %%% "cats-effect" % catsEffectV,
"org.typelevel" %%% "cats-laws" % catsV % Test,
"org.typelevel" %%% "discipline-specs2" % disciplineSpecs2V % Test,
"org.specs2" %%% "specs2-core" % specs2V % Test,
"org.specs2" %%% "specs2-scalacheck" % specs2V % Test
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.typelevel" %%% "cats-effect" % catsEffectV,
"org.typelevel" %%% "cats-laws" % catsV % Test,
"org.typelevel" %%% "discipline-specs2" % disciplineSpecs2V % Test,
"org.specs2" %%% "specs2-core" % specs2V % Test,
"org.specs2" %%% "specs2-scalacheck" % specs2V % Test,
"org.typelevel" %%% "cats-effect-testing-specs2" % catsEffectTestingV % Test
)
)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
package io.chrisdavenport.fuuid

import cats.effect.IO
import org.specs2._
import cats.effect.testing.specs2.CatsEffect
import org.specs2.mutable.Specification

class FUUIDJvmSpec extends mutable.Specification with ScalaCheck {
class FUUIDJvmSpec extends Specification with CatsEffect {

import cats.effect.unsafe.implicits.global

"FUUID.nameBased" should {
"produce a valid UUID" in {
(for {
namespace <- FUUID.randomFUUID[IO]
namebased <- FUUID.nameBased[IO](namespace, "What up yo!")
parsed <- FUUID.fromStringF[IO](namebased.toString)
} yield parsed).attempt
.unsafeRunSync()
.isRight must_=== true
} yield parsed).attempt.map(_.isRight must_=== true)
}

"conform to an example" in {
Expand All @@ -22,7 +23,7 @@ class FUUIDJvmSpec extends mutable.Specification with ScalaCheck {

val expected = FUUID.fromStringF[IO]("1cce4593-d217-5b33-be0d-2e81462e79d3").unsafeRunSync()

FUUID.nameBased[IO](namespace, name).unsafeRunSync() must_=== expected
FUUID.nameBased[IO](namespace, name).map(_ must_=== expected)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package io.chrisdavenport.fuuid

import java.util.UUID

import cats.effect.IO
import org.specs2._
import org.specs2.mutable.Specification
import cats.effect.testing.specs2.CatsEffect

class FUUIDSpec extends mutable.Specification with ScalaCheck {
class FUUIDSpec extends Specification with CatsEffect {

"FUUID.fromString" should {
"Fail when parsing an invalid string" in {
Expand All @@ -18,8 +20,7 @@ class FUUIDSpec extends mutable.Specification with ScalaCheck {
.randomFUUID[IO]
.map(_.toString)
.map(FUUID.fromString)
.map(_.isRight)
.unsafeRunSync() must_=== true
.map(_.isRight must_=== true)
}
}

Expand Down Expand Up @@ -59,7 +60,4 @@ class FUUIDSpec extends mutable.Specification with ScalaCheck {
ok
}
}

// FUUID.fuuid("kasdfasd")

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.chrisdavenport.fuuid.doobie.h2

import cats.effect.{ContextShift, IO}
import cats.effect.IO
import doobie._
import doobie.h2.implicits._
import doobie.implicits._
Expand All @@ -9,11 +9,10 @@ import io.chrisdavenport.fuuid.FUUID
import io.chrisdavenport.fuuid.doobie.implicits._
import org.specs2.mutable.Specification
import org.specs2.specification.BeforeAll
import scala.concurrent.ExecutionContext.Implicits.global

class H2InstanceSpec extends Specification with IOChecker with BeforeAll {

implicit val contextShiftIO: ContextShift[IO] = IO.contextShift(global)
import cats.effect.unsafe.implicits.global

lazy val transactor: Transactor[IO] =
Transactor.fromDriverManager[IO](
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.chrisdavenport.fuuid.doobie.h2

import cats.effect.{ContextShift, IO}
import cats.effect.IO
import doobie._
import doobie.h2.implicits._
import doobie.implicits._
Expand All @@ -9,11 +9,10 @@ import io.chrisdavenport.fuuid._
import org.specs2.ScalaCheck
import org.specs2.mutable.Specification
import org.specs2.specification.BeforeAll
import scala.concurrent.ExecutionContext.Implicits.global

class H2TraversalSpec extends Specification with BeforeAll with ScalaCheck with FUUIDArbitraries {

implicit val contextShiftIO: ContextShift[IO] = IO.contextShift(global)
import cats.effect.unsafe.implicits.global

lazy val transactor: Transactor[IO] =
Transactor.fromDriverManager[IO](
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ import io.chrisdavenport.fuuid.doobie.implicits._
import org.specs2.mutable.Specification
import org.specs2.specification.BeforeAfterAll

import scala.concurrent.ExecutionContext.Implicits.global

class PostgresInstanceSpec extends Specification with IOChecker with BeforeAfterAll {
sequential
implicit val contextShiftIO: ContextShift[IO] = IO.contextShift(global)

import cats.effect.unsafe.implicits.global

lazy val container = PostgreSQLContainer()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@ import org.specs2.ScalaCheck
import org.specs2.mutable.Specification
import org.specs2.specification.BeforeAfterAll

import scala.concurrent.ExecutionContext.Implicits.global

class PostgresTraversalSpec
extends Specification
with ScalaCheck
with FUUIDArbitraries
with BeforeAfterAll {
sequential
implicit val contextShiftIO: ContextShift[IO] = IO.contextShift(global)

import cats.effect.unsafe.implicits.global

lazy val container = PostgreSQLContainer()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,26 @@ package io.chrisdavenport.fuuid.http4s

import io.chrisdavenport.fuuid.{FUUID, FUUIDArbitraries}
import org.http4s.dsl.io._
import org.http4s.implicits._
import org.scalacheck._
import org.specs2.ScalaCheck
import org.specs2.mutable.Specification
import org.http4s.Uri

class FUUIDVarSpec extends Specification with ScalaCheck with FUUIDArbitraries {

"FUUID Extractor in Path" should {

"work properly given a valid UUID" in prop { validFuuid: FUUID =>
(Path(s"/v1/${validFuuid.show}") match {
(path"/v1" / Uri.Path.Segment(validFuuid.show) match {
case Root / "v1" / FUUIDVar(uuid @ _) => uuid.eqv(validFuuid)
case _ => false
}) must beTrue

}

"fail given an invalid UUID" in prop { invalidUuid: String =>
(Path(s"/v1/$invalidUuid") match {
(path"/v1" / Uri.Path.Segment(invalidUuid) match {
case Root / "v1" / FUUIDVar(uuid @ _) => true
case _ => false
}) must beFalse
Expand Down

0 comments on commit 22450ee

Please sign in to comment.