Skip to content

Commit

Permalink
Refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SystemFw committed Jan 25, 2019
1 parent 7634ef8 commit a64640e
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions core/jvm/src/test/scala/fs2/ResourceCompilationSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ import cats.effect.concurrent.{Deferred, Ref}
import scala.concurrent.duration._

class ResourceCompilationSpec extends AsyncFs2Spec {
// NOTE: still doesn't work. There are Release nodes being inserted, whose finaliser gets called anyway.
// Basic is the minimised case

"compile.toResource - concurrently" in {
val prog: Resource[IO, IO[Unit]] =
Stream
Expand Down Expand Up @@ -73,16 +70,20 @@ class ResourceCompilationSpec extends AsyncFs2Spec {
.map(_ shouldBe expected)
}

"basic test" in {
Stream
.emit(())
.onFinalize(IO(println("done")))
.compile
.toResource
.lastOrError
.allocated
.map(_._1)
"compile.toResource - allocated" in {
Ref[IO]
.of(false)
.flatMap { written =>
Stream
.emit(())
.onFinalize(written.set(true))
.compile
.toResource
.lastOrError
.allocated >> written.get
}
.unsafeToFuture
.map(written => written shouldBe false)
}
}

Expand Down

0 comments on commit a64640e

Please sign in to comment.