Description
In some context, it would be useful to be able to block and wait for a promise to be resolved or rejected.
Typically, I want to test with testthat
some code that acts on futures or promises, so I want to synchronously check that the resolved value is correct. The future
API offers the value
method but it is not implemented by promises
.
I see how you solved this with the extract
function in tests/testthat/common.R
. It would be useful to have access to this blocking extract
function from the package, without confusing the end-users who shouldn't use it.
How about as a non-exported function such as promises:::extract_block
or promises:::value
?
Or maybe it would be neater if testthat
was promise-aware, with e.g. expect_promise_resolved
and expect_promise_rejected
?