akka/akka-core

StubbedActorContext.scheduleOnce returns canceled Cancellable

Open

#28,596 opened on Feb 11, 2020

View on GitHub
 (1 comment) (0 reactions) (0 assignees)Scala (3,547 forks)batch import
1 - triagedhelp wantedt:testingt:typed

Repository metrics

Stars
 (13,277 stars)
PR merge metrics
 (Avg merge 8d 19h) (10 merged PRs in 30d)

Description

The current implementation of StubbedActorContext.scheduleOnce always returns an already canceled Cancellable. This makes it impossible to test any logic that relies on the state of the scheduled event (keeping an existing one vs. creating a new one based on its state).

Since one would expect to succeed in scheduling a new event with StubbedActorContext.scheduleOnce, shouldn't the stub returned be one that is uncancelle and transitions to cancelled if .cancel()` is called? If that change in behavior is acceptable, I'd gladly provide a PR for it.

Contributor guide