Skip to content

Commit

Permalink
Test cancelling during checks
Browse files Browse the repository at this point in the history
  • Loading branch information
Krever committed Apr 16, 2024
1 parent f2af254 commit 3bd0801
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import workflow4s.example.testuitls.TestUtils.SimpleSignalResponseOps
import workflow4s.wio.model.{WIOModel, WIOModelInterpreter}
import workflow4s.wio.simple.{InMemoryJournal, SimpleActor}
import io.circe.syntax.*
import org.scalatest.Inside.inside
import workflow4s.example.checks.StaticCheck
import workflow4s.example.withdrawal.checks.{Check, CheckResult, ChecksEngine, ChecksInput, ChecksState, Decision}
import workflow4s.example.withdrawal.{WithdrawalData, WithdrawalEvent, WithdrawalService, WithdrawalSignal, WithdrawalWorkflow}
Expand Down Expand Up @@ -140,6 +141,23 @@ class WithdrawalWorkflowTest extends AnyFreeSpec with MockFactory {
checkRecovery()
}

"when running checks" in new Fixture {
val check = StaticCheck(CheckResult.Pending())
withFeeCalculation(fees)
withMoneyOnHold(success = true)
withChecks(List(check))
withFundsLockCancelled()

actor.init(CreateWithdrawal(amount, recipient))
inside(actor.queryData()) { case data: WithdrawalData.Checking =>
assert(data.checkResults.results == Map(check.key -> CheckResult.Pending()))
}
actor.cancel(WithdrawalSignal.CancelWithdrawal("operator-1", "cancelled", acceptStartedExecution = true))
assert(actor.queryData() == WithdrawalData.Completed.Failed("Cancelled by operator-1. Comment: cancelled"))

checkRecovery()
}

}
}

Expand Down

0 comments on commit 3bd0801

Please sign in to comment.