Simplified the test cases for Future.or
This commit is contained in:
parent
a019c9e8a6
commit
3f0b1772c8
1 changed files with 8 additions and 9 deletions
|
|
@ -49,17 +49,16 @@ class FutureSpec extends AkkaSpec with Checkers with BeforeAndAfterAll with Defa
|
|||
"never completed" must {
|
||||
behave like emptyFuture(_(Promise()))
|
||||
"return supplied value on timeout" in {
|
||||
val f = new RuntimeException("br0ken")
|
||||
val failure = Promise.failed[String](new RuntimeException("br0ken"))
|
||||
val otherFailure = Promise.failed[String](new RuntimeException("last"))
|
||||
val empty = Promise[String]()
|
||||
val timedOut = Promise.successful[String]("Timedout")
|
||||
val promise1 = Promise.failed[String](f) or timedOut
|
||||
val promise2 = timedOut or Promise[String]()
|
||||
val promise3 = Promise.failed[String](f) or Promise.failed[String](f) or timedOut
|
||||
val promise4 = Promise.failed[String](f) or Promise.failed[String](new RuntimeException("last"))
|
||||
Await.result(promise1, timeout.duration) must be("Timedout")
|
||||
Await.result(promise2, timeout.duration) must be("Timedout")
|
||||
Await.result(promise3, timeout.duration) must be("Timedout")
|
||||
|
||||
Await.result(failure or timedOut, timeout.duration) must be("Timedout")
|
||||
Await.result(timedOut or empty, timeout.duration) must be("Timedout")
|
||||
Await.result(failure or failure or timedOut, timeout.duration) must be("Timedout")
|
||||
intercept[RuntimeException] {
|
||||
Await.result(promise4, timeout.duration)
|
||||
Await.result(failure or otherFailure, timeout.duration)
|
||||
}.getMessage must be("last")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue