forked from Kazark/doobie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CheckerTests.scala
41 lines (29 loc) · 1.08 KB
/
CheckerTests.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright (c) 2013-2020 Rob Norris and Contributors
// This software is licensed under the MIT License (MIT).
// For more information see LICENSE or https://opensource.org/licenses/MIT
package doobie.munit
import cats.effect.{ ContextShift, IO }
import doobie.syntax.string._
import doobie.util.transactor.Transactor
import munit._
import scala.concurrent.ExecutionContext
trait CheckerChecks[M[_]] extends FunSuite with Checker[M] {
implicit def contextShift: ContextShift[M]
lazy val transactor = Transactor.fromDriverManager[M](
"org.h2.Driver",
"jdbc:h2:mem:queryspec;DB_CLOSE_DELAY=-1",
"sa", ""
)
test("trivial") { check(sql"select 1".query[Int]) }
test("fail".fail) { check(sql"select 1".query[String]) }
final case class Foo[F[_]](x: Int)
test ("trivial case-class"){ check(sql"select 1".query[Foo[cats.Id]]) }
test("suspended") {
val _ = check(sql"select 1".query[String])
assert(true)
}
}
class IOCheckerCheck extends CheckerChecks[IO] with IOChecker {
def contextShift: ContextShift[IO] =
IO.contextShift(ExecutionContext.global)
}