You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
883 B

3 years ago
  1. package wow.doge.http4sdemo
  2. import cats.syntax.all._
  3. import io.odin.consoleLogger
  4. import io.odin.fileLogger
  5. import io.odin.syntax._
  6. import monix.bio.Task
  7. import monix.execution.Scheduler
  8. import scala.concurrent.Future
  9. import munit.TestOptions
  10. import cats.effect.Resource
  11. import io.odin.Logger
  12. trait MonixBioSuite extends munit.TaglessFinalSuite[Task] {
  13. override protected def toFuture[A](f: Task[A]): Future[A] = {
  14. implicit val s = Scheduler.global
  15. f.runToFuture
  16. }
  17. def loggerFixture(fileName: Option[String] = None)(implicit
  18. enc: sourcecode.Enclosing
  19. ) =
  20. ResourceFixture(
  21. consoleLogger[Task]().withAsync() |+| fileLogger[Task](
  22. fileName.getOrElse(enc.value.split("#").head + ".log")
  23. ),
  24. (
  25. options: TestOptions,
  26. value: Logger[Task]
  27. ) => Task(options.name),
  28. (_: Logger[Task]) => Task.unit
  29. )
  30. }