-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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 delaySubscription() methods to Completable #5081 #6242
Conversation
Please fix the mistakes and add unit tests verifying these new methods. |
The code failed this test Which should I better do:
The first way looks more logical to me. |
Neither. Update the test to permit any integer like the other |
Got it. I will fix the tests. What about https://github.com/ReactiveX/RxJava/blob/2.x/src/main/java/io/reactivex/Completable.java#L909 |
You don't have to |
Should I remove Can I add |
Sure.
Add |
Codecov Report
@@ Coverage Diff @@
## 2.x #6242 +/- ##
============================================
+ Coverage 98.25% 98.29% +0.04%
- Complexity 6199 6202 +3
============================================
Files 667 667
Lines 44887 44889 +2
Branches 6216 6216
============================================
+ Hits 44104 44125 +21
+ Misses 243 239 -4
+ Partials 540 525 -15
Continue to review full report at Codecov.
|
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.
Please add unit tests that verify the expected behavior.
scheduler.advanceTimeBy(15, TimeUnit.MILLISECONDS); | ||
|
||
to.assertEmpty(); | ||
verify(o, never()).onComplete(); |
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.
No need to talk to a mocked observer, TestObserver.assertEmpty() already verifies these.
to.dispose(); | ||
scheduler.advanceTimeBy(15, TimeUnit.MILLISECONDS); | ||
|
||
verify(o, never()).onComplete(); |
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.
No need to talk to a mocked observer, TestObserver.assertEmpty() already verifies these.
scheduler.advanceTimeBy(15, TimeUnit.MILLISECONDS); | ||
to.assertComplete(); | ||
|
||
verify(o, never()).onError(any(Throwable.class)); |
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.
No need to talk to a mocked observer, TestObserver.assertEmpty() already verifies these.
scheduler.advanceTimeBy(90, TimeUnit.MILLISECONDS); | ||
to.assertEmpty(); | ||
scheduler.advanceTimeBy(15, TimeUnit.MILLISECONDS); | ||
to.assertComplete(); |
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.
to.assertResult();
will check for the no-error condition.
Thanks a lot for explanations! May I simply edit the last commit, because I gave a wrong title to the commit with tests (8233972)? |
Just commit the changes as fresh. |
scheduler.advanceTimeBy(90, TimeUnit.MILLISECONDS); | ||
to.assertEmpty(); | ||
scheduler.advanceTimeBy(15, TimeUnit.MILLISECONDS); | ||
to.assertResult(); |
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.
nit: here we rely just on completion signal, which as an implementation bug may be emitted by delaySubscription
operator. I mean, right now there is obviously no bug, but in future if operator will be re-implemented, it might appear
Thus I'd recommend to add verifiable logic to the upstream, like Completable.fromAction { if (!atomicBoolean.compareAndSet(false, true)) throw IllegalStateException() }
and verify against that too:
to.assertResult()
assertTrue(atomicBoolean.get())
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'll add the extra tests in a separate 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.
Thank you, @akarnokd
@soshial do you want to address @artem-zinnatullin 's review? |
Since Observable, Single already have
delaySubscription()
, but Completable doesn't, I added these methods to the code.