Skip to content

Commit

Permalink
alsoToTap - add test cases verifying that when other sink fails/compl…
Browse files Browse the repository at this point in the history
…etes, it's ignored
  • Loading branch information
micossow committed Jul 2, 2024
1 parent 3a7a3b3 commit d5ac142
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions core/src/test/scala/ox/channels/SourceOpsAlsoToTapTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,28 @@ class SourceOpsAlsoToTapTest extends AnyFlatSpec with Matchers {
val otherElements = slowConsumerFork.join()
otherElements.size should be < 10
}

it should "not fail the channel when the other sink fails" in supervised {
val other = Channel.rendezvous[Int]
val f = fork {
val v = other.receiveOrClosed()
other.error(new RuntimeException("boom!"))
v
}
Source.fromValues(1, 2, 3).alsoToTap(other).map(v => { sleep(50.millis); v }).toList shouldBe List(1, 2, 3)
f.join() shouldBe 1
}

it should "not close the channel when the other sink closes" in supervised {
val other = Channel.rendezvous[Int]
val f = fork {
val v = other.receiveOrClosed()
other.done()
v
}
Source.fromValues(1, 2, 3).alsoToTap(other).map(v => {
sleep(50.millis); v
}).toList shouldBe List(1, 2, 3)
f.join() shouldBe 1
}
}

0 comments on commit d5ac142

Please sign in to comment.