Skip to content

Commit

Permalink
Uses cats-effect 3.3.11 to use custom uuid generation
Browse files Browse the repository at this point in the history
  • Loading branch information
daddykotex committed Apr 13, 2022
1 parent a5b52b9 commit 0315994
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
15 changes: 12 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,11 @@ lazy val http4s = projectMatrix
.settings(
isCE3 := virtualAxes.value.contains(CatsEffect3Axis),
libraryDependencies ++= {
Seq(
val ce3 =
if (isCE3.value) Seq(Dependencies.CatsEffect.value)
else Seq.empty

ce3 ++ Seq(
Dependencies.Http4s.core.value,
Dependencies.Http4s.dsl.value,
Dependencies.Http4s.client.value,
Expand Down Expand Up @@ -547,8 +551,11 @@ lazy val tests = projectMatrix
.settings(
isCE3 := virtualAxes.value.contains(CatsEffect3Axis),
libraryDependencies ++= {
val ce3 =
if (isCE3.value) Seq(Dependencies.CatsEffect.value)
else Seq.empty

Seq(
ce3 ++ Seq(
Dependencies.Http4s.core.value,
Dependencies.Http4s.dsl.value,
Dependencies.Http4s.emberClient.value,
Expand Down Expand Up @@ -669,14 +676,16 @@ lazy val Dependencies = new {
Def.setting("io.circe" %%% "circe-generic" % "0.14.1")
}

val CatsEffect: Def.Initialize[ModuleID] =
Def.setting("org.typelevel" %%% "cats-effect" % "3.3.11")

object Http4s {
val http4sVersion = Def.setting(if (isCE3.value) "0.23.11" else "0.22.12")

val emberServer: Def.Initialize[ModuleID] =
Def.setting("org.http4s" %%% "http4s-ember-server" % http4sVersion.value)
val emberClient: Def.Initialize[ModuleID] =
Def.setting("org.http4s" %%% "http4s-ember-client" % http4sVersion.value)

val circe: Def.Initialize[ModuleID] =
Def.setting("org.http4s" %%% "http4s-circe" % http4sVersion.value)
val core: Def.Initialize[ModuleID] =
Expand Down
8 changes: 8 additions & 0 deletions modules/tests/src-ce2/UUIDGen.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package cats.effect.std

import java.util.UUID
import cats.effect._

object UUIDGen {
def randomUUID[F[_]: Sync]: F[UUID] = Sync[F].delay(UUID.randomUUID())
}
3 changes: 2 additions & 1 deletion modules/tests/src/smithy4s/tests/PizzaAdminServiceImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import smithy4s.example._
import java.util.UUID

import PizzaAdminServiceImpl._
import cats.effect.std.UUIDGen

object PizzaAdminServiceImpl {
case class Item(food: Food, price: Float, addedAt: Timestamp)
Expand All @@ -50,7 +51,7 @@ class PizzaAdminServiceImpl(ref: Compat.Ref[IO, State])
PriceError(s"Prices must be whole numbers: ${menuItem.price}")
)
.unlessA(menuItem.price.isWhole)
uuid <- IO(java.util.UUID.randomUUID())
uuid <- UUIDGen.randomUUID[IO]
timestamp <- IO(Timestamp.nowUTC())
_ <- ref.update { state =>
val item = Item(menuItem.food, menuItem.price, timestamp)
Expand Down
6 changes: 2 additions & 4 deletions modules/tests/src/smithy4s/tests/PizzaClientSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package smithy4s.tests

import cats.data.Chain
import cats.effect.Resource
import cats.effect._
import cats.effect.std.UUIDGen
import cats.syntax.all._
import io.circe.Json
import org.http4s.HttpApp
Expand All @@ -31,8 +31,6 @@ import smithy4s.Timestamp
import smithy4s.example._
import weaver._

import java.util.UUID

abstract class PizzaClientSpec extends IOSuite {

val pizzaItem = Json.obj(
Expand All @@ -49,7 +47,7 @@ abstract class PizzaClientSpec extends IOSuite {
clientTest("Errors make it through") { (client, backend, log) =>
for {
ts <- IO(Timestamp.nowUTC())
uuid <- IO(UUID.randomUUID())
uuid <- UUIDGen.randomUUID[IO]
response <- Created(
Json.fromString(uuid.toString),
Header.Raw(
Expand Down

0 comments on commit 0315994

Please sign in to comment.