-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a way to block and wait for a promise (for testing) #48
Comments
Tricky... I'm not sure ::: would be allowed on CRAN. We could make it :: but not include it in the package index? 😐 For sure though, it's super useful for testing. For now I'd encourage anyone who needs this to just copy our code. |
I believe |
Oooh, that's perfect then. |
If we do this, |
For testing in crrri with promises, we used a It is one approach that helps us cover with tests all the code using promises. I just mention this here if you have feedback on doing things better or if it could help others for testing with promises. |
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. Thefuture
API offers thevalue
method but it is not implemented bypromises
.I see how you solved this with the
extract
function intests/testthat/common.R
. It would be useful to have access to this blockingextract
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
orpromises:::value
?Or maybe it would be neater if
testthat
was promise-aware, with e.g.expect_promise_resolved
andexpect_promise_rejected
?The text was updated successfully, but these errors were encountered: