package wow.doge.mygame

import org.scalatest.funsuite.AnyFunSuite
import cats.effect.{Resource => CResource}
import monix.eval.Task
import scala.concurrent.duration._

class FileWatcherTest extends AnyFunSuite {
  test("1") {
    import better.files._
    import io.methvin.better.files._

    val myDir =
      File((os.pwd / "assets" / "scripts").toString)
    val watcher = new RecursiveFileMonitor(myDir) {
      override def onCreate(file: File, count: Int) =
        println(s"$file got created")
      override def onModify(file: File, count: Int) =
        println(s"$file got modified $count times")
      override def onDelete(file: File, count: Int) =
        println(s"$file got deleted")
    }

    import monix.execution.Scheduler.Implicits.global
    CResource
      .make(Task { watcher.start(); watcher })(w => Task(w.stop()))
      .use(_ => Task.never)
      .runSyncUnsafe(10.seconds)
  }
}
