Skip to content

Instantly share code, notes, and snippets.

@jmcardon
Created February 17, 2018 21:56
Show Gist options
  • Save jmcardon/84bdd80a7e8bf1e077d7101dee15147e to your computer and use it in GitHub Desktop.
Save jmcardon/84bdd80a7e8bf1e077d7101dee15147e to your computer and use it in GitHub Desktop.
import java.util.concurrent.Executors
import cats.effect._
import fs2._
import org.scalatest.{FlatSpec, MustMatchers}
import scala.concurrent.duration._
import scala.concurrent.ExecutionContext
class TestNStuff extends FlatSpec with MustMatchers {
def bracketEC =
Stream.bracket(IO(
ExecutionContext.fromExecutorService(Executors.newFixedThreadPool(10))))(
Stream.emit(_),
s => IO(s.shutdown())
)
val initializeStuff = for {
sc <- Scheduler[IO](1)
pool <- bracketEC
} yield (sc, pool)
initializeStuff.evalMap {
case (sc, pool) =>
implicit val p = pool
IO {
behavior of "wtf"
it should "not explode" in {
sc.sleep[IO](1.second).map(_ =>
1
).compile.last.unsafeRunSync() mustBe (1)
}
}
}.compile.drain.unsafeRunSync()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment