Skip to content

Commit

Permalink
Fix race condition in groupedWeighted* tests (#171)
Browse files Browse the repository at this point in the history
  • Loading branch information
micossow authored Jul 3, 2024
1 parent 2121658 commit a32e6c6
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions core/src/test/scala/ox/channels/SourceOpsGroupedTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ class SourceOpsGroupedTest extends AnyFlatSpec with Matchers {
}

it should "return failed source when cost function throws exception" in supervised {
val source = Source.fromValues(1, 2, 3, 0, 4, 5, 6, 7).groupedWeighted(150)(n => 100 / n)
source.receiveOrClosed() shouldBe Seq(1, 2)
source.receiveOrClosed() should matchPattern {
val result = Source.fromValues(1, 2, 3, 0, 4, 5, 6, 7).groupedWeighted(150)(n => 100 / n).drainOrError()
result should matchPattern {
case ChannelClosed.Error(reason) if reason.isInstanceOf[ArithmeticException] =>
}
}
Expand Down Expand Up @@ -154,9 +153,8 @@ class SourceOpsGroupedTest extends AnyFlatSpec with Matchers {
}

it should "return failed source when cost function throws exception" in supervised {
val source = Source.fromValues(1, 2, 3, 0, 4, 5, 6, 7).groupedWeightedWithin(150, 100.millis)(n => 100 / n)
source.receiveOrClosed() shouldBe Seq(1, 2)
source.receiveOrClosed() should matchPattern {
val result = Source.fromValues(1, 2, 3, 0, 4, 5, 6, 7).groupedWeightedWithin(150, 100.millis)(n => 100 / n).drainOrError()
result should matchPattern {
case ChannelClosed.Error(reason) if reason.isInstanceOf[ArithmeticException] =>
}
}
Expand Down

0 comments on commit a32e6c6

Please sign in to comment.