Skip to content

Commit

Permalink
fix QueryLogSuite
Browse files Browse the repository at this point in the history
  • Loading branch information
jatcwang committed Jan 31, 2025
1 parent 3645b8d commit cde7e77
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions modules/core/src/test/scala/doobie/util/QueryLogSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,22 @@ import doobie.util.update.Update

class QueryLogSuite extends munit.CatsEffectSuite with QueryLogSuitePlatform {

val logEventRef: IO[Ref[IO, LogEvent]] =
Ref.of[IO, LogEvent](null)
val logEventRef: Ref[IO, LogEvent] =
Ref.of[IO, LogEvent](null).unsafeRunSync()

val xa = Transactor.fromDriverManager[IO](
"org.h2.Driver",
"jdbc:h2:mem:queryspec;DB_CLOSE_DELAY=-1",
"sa",
"",
logHandler = Some(ev => logEventRef.unsafeRunSync().set(ev))
logHandler = Some(ev => logEventRef.set(ev))
)

def eventForCIO[A](cio: ConnectionIO[A]): IO[LogEvent] = {
for {
_ <- logEventRef.flatMap(_.set(null))
_ <- logEventRef.set(null)
_ <- cio.transact(xa).attempt
log <- logEventRef.flatMap(_.get)
log <- logEventRef.get
} yield log
}

Expand Down

0 comments on commit cde7e77

Please sign in to comment.