-
Notifications
You must be signed in to change notification settings - Fork 103
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
Add testing util to poll for async event testing #758
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #758 +/- ##
==========================================
+ Coverage 98.55% 98.62% +0.07%
==========================================
Files 73 73
Lines 10929 10929
Branches 1573 1577 +4
==========================================
+ Hits 10771 10779 +8
+ Misses 152 144 -8
Partials 6 6 ☔ View full report in Codecov by Sentry. |
644acab
to
e647146
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐐
The number the tests you have for subscription is astounding!
14ec331
to
35b5986
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
Consider renaming the test to "root/context role authorized ..." for clarity in a future PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐐
I needed to test async events on another project. I initially polled to make sure the event had finished, but the tests were taking a long time. Instead, I created a promise in the test code that I resolved in the event handler, and the tests ran 2-3 times faster. I don't know if this approach is appropriate for what you're doing, but I thought I'd mention it. |
Due to the async nature of testing
EventStream
and Subscriptions, and some external pub/sub systems taking a longer time to publish and/or receive a message, we have added a helper method to help wait for a test case to assert.Additionally we modified the tests to be able to more accurately check negative test cases where testing the absence of something which arrives async could be challenging.
pollUntilSuccessOrTimeout
will execute a delegate function passed to it, if it fails it will sleepretrySleep
ms, and will retry. If the total retry time exceedstimeout
, it will finally fail.