Skip to content

Commit

Permalink
added a test case for the addLast method with the future effect
Browse files Browse the repository at this point in the history
  • Loading branch information
etorreborre committed Mar 22, 2017
1 parent 85d9e3b commit 57ab6f9
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion jvm/src/test/scala/org/atnos/eff/FutureEffectSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ class FutureEffectSpec(implicit ee: ExecutionEnv) extends Specification with Sca
Simple Future calls with timeout can be memoized $e11
Attempted Future calls with timeout can be memoized $e12

TimedFuture calls can be memoized with a memo effect $e10
TimedFuture calls can be memoized with a memo effect $e13
addLast can be used to make sure an action executes when a future fails $e11


"""
Expand Down Expand Up @@ -158,6 +159,26 @@ class FutureEffectSpec(implicit ee: ExecutionEnv) extends Specification with Sca
invocationsNumber must be_==(1)
}

def e14 = {
type S = Fx2[TimedFuture, Option]
var lastActionDone = false

val action: Eff[S, Int] =
for {
i <- futureDelay[S, Int] { sleepFor(10.millis); 1 }
_ <- futureFail[S, Int](new Exception("boom"))
j = i + 1
} yield j

val execute: Eff[S, Throwable Either Int] =
action.
addLast(futureDelay[S, Unit](lastActionDone = true)).
futureAttempt

execute.runOption.runSequential must beSome(beLeft[Throwable]).awaitFor(20.seconds)
lastActionDone must beTrue
}

/**
* HELPERS
*/
Expand Down

0 comments on commit 57ab6f9

Please sign in to comment.