diff --git a/src/main/scala/net/yoshinorin/qualtet/infrastructure/db/Migrator.scala b/src/main/scala/net/yoshinorin/qualtet/infrastructure/db/Migrator.scala index 3f266e8a..819ad421 100644 --- a/src/main/scala/net/yoshinorin/qualtet/infrastructure/db/Migrator.scala +++ b/src/main/scala/net/yoshinorin/qualtet/infrastructure/db/Migrator.scala @@ -14,7 +14,7 @@ class Migrator(config: DBConfig) { /** * Do migration */ - def migrate[F[_]: Monad](contentTypeService: ContentTypeService[F]): Unit = { + def migrate[F[_]: Monad](contentTypeService: ContentTypeService[F]) = { val _ = flyway.migrate() (for { _ <- contentTypeService.create(ContentType(name = "article")) @@ -34,7 +34,7 @@ class Migrator(config: DBConfig) { * DROP all tables and re-create * NOTE: for development */ - def recrate[F[_]: Monad](contentTypeService: ContentTypeService[F]): Unit = { + def recrate[F[_]: Monad](contentTypeService: ContentTypeService[F]) = { this.clean() this.migrate(contentTypeService) } diff --git a/src/test/scala/net/yoshinorin/qualtet/infrastructure/db/MigratorSpec.scala b/src/test/scala/net/yoshinorin/qualtet/infrastructure/db/MigratorSpec.scala index fe920e47..e94c3056 100644 --- a/src/test/scala/net/yoshinorin/qualtet/infrastructure/db/MigratorSpec.scala +++ b/src/test/scala/net/yoshinorin/qualtet/infrastructure/db/MigratorSpec.scala @@ -1,6 +1,5 @@ package net.yoshinorin.qualtet.infrastructure.db -import cats.effect.IO import net.yoshinorin.qualtet.fixture.Fixture.contentTypeService import net.yoshinorin.qualtet.Modules import net.yoshinorin.qualtet.infrastructure.db.doobie.DoobieTransactor @@ -16,14 +15,16 @@ class MigratorSpec extends AnyWordSpec { "Migrator" should { "be migrate" in { - val (a, p) = (for { - _ <- IO(Modules.migrator.migrate(contentTypeService)) + + Modules.migrator.migrate(contentTypeService).unsafeRunSync() + + val result = (for { a <- contentTypeService.findByName("article") p <- contentTypeService.findByName("page") } yield (a, p)).unsafeRunSync() - assert(a.isDefined) - assert(p.isDefined) + assert(result._1.isDefined) + assert(result._2.isDefined) } }