-
Notifications
You must be signed in to change notification settings - Fork 59
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
Test failing at ProjectCacheImplTest isProjectCacheExpired #5
Comments
Same error... |
I am facing the same issue too |
The following will fix this:
Sorry about that, I was using the incorrect value for the cache check. Here we now:
Here, previously lastCacheTime was 1000 which meant the incorrect value was always being used in the calculation. @jeanPokou @AlanUeyn @ninad458 does this work for you here? |
Thanks, @hitherejoe It is working now |
Hello Joe. It remains with error for the test of test method isProjectsCacheExpiredReturnsNotExpired:
Also the same error happens for this other test method isProjectsCacheExpiredReturnsExpired. |
Hi, @graffiti75 what version of Robolectric are you using? you should upgrade to 4.0.2. I was finally able to make it work with @Test
fun isProjectCacheReturnsExpired() {
projectsCacheLocal.setLastCacheTime(1000L).test()
projectsCacheLocal.isProjectsCacheExpired().test().assertValue(true)
}
@Test
fun isProjectsCacheReturnsNotExpired() {
projectsCacheLocal.setLastCacheTime(System.currentTimeMillis()).test()
projectsCacheLocal.isProjectsCacheExpired().test().assertValue(true)
} Here is the isProjectsCachedExpired function override fun isProjectsCacheExpired(): Single<Boolean> {
val currentTime = System.currentTimeMillis()
val expirationInterval =(1000 * 60 * 60 ).toLong() // 1 hour
return projectsDataBase.configDao().getConfig()
.single(
// if config empty set last cache time to zero
Config(lastCacheTime = 0)).map {
currentTime - it.lastCacheTime > expirationInterval
}
} Ps: You may have differents functions names |
Version 3.4.2. I tried updating the Robolectric version, but the same errors persists. |
GithubTrending/cache/src/test/java/co/joebirch/cache/ProjectsCacheImplTest.kt
Line 98 in da09a1d
The text was updated successfully, but these errors were encountered: