Closed russhwolf closed 2 years ago
I did some partial work on this when starting #189, then pulled back because it was a bigger rabbit-hole than I realized. Was having trouble getting tests to pass with MockEngine and seeing some different behavior per-platform, so I'd like to do a bunch of cleanup and get this stuff all working better.
Please review and see if still relevant. If not, close, otherwise, I guess let's chat or just do it if not huge?
Points 5 and 6 have been fixed but the rest of stuff in here is still outstanding
Things I'd like to change:
refreshBreedsIfStale()
andgetBreedsFromCache()
. We should have a single function that coordinates things internally so callers (both platform viewmodels and tests) don't have to.getBreedsFromNetwork()
returns aDataState
, but this is actually only called internally insiderefreshBreedsIfStale()
which creates its ownDataState
. This gets a bit awkward because we need awhen
statement to convert the network call to the final state inrefreshBreedsIfStale()
, but not all cases of thewhen
actually happen in practice (eg the loading state never triggers). We should wait to convert to aDataState
until the last-mile function that gets called externallygetBreedsFromCache()
will never emit if the database is empty. If we always refresh before calling it then this won't be a problem, but callers need to know this.BreedModelTest
are inaccurate and confusing.staleDataCheckTest()
asserts on errors that probably shouldn't be happening, andnotifyErrorOnException()
doesn't assert on any errors even though it expects them to happen ~5.KtorApiMock
is currently a separate implementation ofKtorApi
. We could test our network/serialization logic more directly if it usedDogApiImpl
but passed aMockEngine
to thehttpClient
.~ ~6. ShouldKtorApi
be renamedDogApi
?~