From 3e5a0e1eb4c7424b611ccc8bc7e88b811f2a5002 Mon Sep 17 00:00:00 2001 From: Luca Tassinari Date: Thu, 22 Feb 2024 00:44:05 +0100 Subject: [PATCH] fix(rears): add tolerance to a too strict test --- .../github/tassiLuca/rears/PipelineTransformationsTest.scala | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/rears-core/src/test/scala/io/github/tassiLuca/rears/PipelineTransformationsTest.scala b/rears-core/src/test/scala/io/github/tassiLuca/rears/PipelineTransformationsTest.scala index 8a75de3c..969c23a2 100644 --- a/rears-core/src/test/scala/io/github/tassiLuca/rears/PipelineTransformationsTest.scala +++ b/rears-core/src/test/scala/io/github/tassiLuca/rears/PipelineTransformationsTest.scala @@ -33,14 +33,15 @@ class PipelineTransformationsTest extends AnyFunSpec with Matchers { it("return a new channel that emit an item if the given timespan has passed without emitting anything") { val span = 2.seconds + val tolerance = 10.milliseconds Async.blocking: val debounced = infiniteProducer().debounce(span) debounced.read() + val before = System.currentTimeMillis() for _ <- 1 to 4 do - val before = System.currentTimeMillis() debounced.read() val now = System.currentTimeMillis() - now - before should be > span.toMillis + now - before should be > (span.toMillis - tolerance.toMillis) } }