Created
February 17, 2018 21:56
-
-
Save jmcardon/84bdd80a7e8bf1e077d7101dee15147e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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