pjfanning commented on code in PR #1424:
URL: https://github.com/apache/pekko/pull/1424#discussion_r1966511388


##########
actor-tests/src/test/scala/org/apache/pekko/pattern/PatternSpec.scala:
##########
@@ -76,4 +74,22 @@ class PatternSpec extends PekkoSpec {
       intercept[IllegalStateException] { Await.result(r, remainingOrDefault) 
}.getMessage should ===("Mexico")
     }
   }
+
+  "pattern.timeout" must {
+    "be completed successfully eventually" in {
+      val f = pekko.pattern.timeout(1.second, using = 
system.scheduler)(Future.successful(5))
+      Await.result(f, remainingOrDefault) should ===(5)
+    }
+
+    "be completed abnormally eventually" in {
+      val f = pekko.pattern.timeout(1.second, using = 
system.scheduler)(Future.failed(new IllegalStateException("ABC")))
+      intercept[IllegalStateException] { Await.result(f, remainingOrDefault) 
}.getMessage should ===("ABC")
+    }
+
+    "be completed with a TimeoutException if not completed within the 
specified time" in {
+      val f = pekko.pattern.timeout(1.second, using = 
system.scheduler)(Future.never)

Review Comment:
   Can you use a shorter timeout? I don't see why the test needs to always take 
1 second (or more). I think you should also check that the elapsed time for the 
test is greater than or equal to the timeout - maybe with a small delta (allow 
a few milliseconds leeway).



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@pekko.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@pekko.apache.org
For additional commands, e-mail: notifications-h...@pekko.apache.org

Reply via email to