Skip to content

Commit

Permalink
test(smart): uncomment test controller
Browse files Browse the repository at this point in the history
  • Loading branch information
tassiluca committed Feb 22, 2024
1 parent c378f57 commit 88a5f77
Showing 1 changed file with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package io.github.tassiLuca.rears
import gears.async.TaskSchedule.Every
import gears.async.default.given
import gears.async.{Async, AsyncOperations, SendableChannel, Task, TaskSchedule, UnboundedChannel}

import org.scalatest.flatspec.AnyFlatSpec
import org.scalatest.matchers.should.Matchers

import scala.util.Try
import scala.collection.immutable.Seq
import scala.util.{Success, Try}

class ControllerTest extends AnyFlatSpec with Matchers:

Expand All @@ -27,14 +27,11 @@ class ControllerTest extends AnyFlatSpec with Matchers:
consumers.foreach(_.asRunnable.run)
producer.asRunnable.run.await
// TODO: improve with an extension method that wait for a certain amount of time,
// at the expiration of which the channel are closed and stop blocking!
// at the expiration of which the channel are closed and stop blocking!
AsyncOperations.sleep(2_000) // Ensure consumers have completed their reaction to publisher's events
println(consumerAValues)
println(consumerBValues)
consumerAValues shouldEqual consumerBValues
// TODO: due to asynchrony, the first item may be lost :(
// consumerAValues.size shouldBe items
// consumerBValues.size shouldBe items
consumerAValues shouldBe Seq.range(0, items).map(Success(_))
consumerBValues shouldBe Seq.range(0, items).map(Success(_))
}

def publisher: Publisher[Item] = new Publisher[Int]:
Expand Down

0 comments on commit 88a5f77

Please sign in to comment.