-
Notifications
You must be signed in to change notification settings - Fork 16
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
Make dispatchers overriding for DODW publicly available and resettable #41
Conversation
|
||
val delegate = DataObservableDelegateWrapper<Unit, String>( | ||
fromNetwork = { | ||
delay(3.seconds) |
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.
Verifies that delays are actually skipped (in combination with 1s timeout for the whole test)
|
||
DataObservableDelegateWrapperDispatchers.setDispatchers(testDispatcher) | ||
DataObservableDelegateWrapperDispatchers.IO shouldBe testDispatcher | ||
DataObservableDelegateWrapperDispatchers.Unconfined shouldBe testDispatcher |
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.
these are cluttering this test case IMO, if you want to test the setter/getter behaviour better be done separately
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.
Done 😄
} | ||
networkDispatcher shouldBe testDispatcher | ||
|
||
DataObservableDelegateWrapperDispatchers.resetDispatchers() |
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.
same here, just move out set/get/reset assertions in a separate test case
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.
Done 😄
fun resetDispatchers() { | ||
IO = Dispatchers.IO | ||
Unconfined = Dispatchers.Unconfined |
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'd reuse this method in init phase as well, not repeat IO = Dispatchers.IO / Unconfined = Dispatchers.Unconfined twice
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.
We'll need to declare the properties as lateinit
, otherwise compiler is not satisfied. Do you think it's worth it?
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.
sounds fair, unless you see any issues with that
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.
Done 😄
DataObservableDelegateWrapperDispatchers
was initially marked as internal because I wasn't sure it's really needed: typical DOD usage was already testable synchronously thanks toDispatchers.Unconfined
infromNetwork
.But recently we hit the case where
fromNetwork
contains internal loop with delays to implement polling. These delays are not skippable without injecting someTestDispatcher
.We should also provide the means to reset dispatchers, to keep tests self-contained and independent of each other.