splendo / kaluga

Collection of multiplatform kotlin components, mainly using coroutines and flow
Apache License 2.0
318 stars 7 forks source link

Add support for safely stopping a timer #815

Closed Daeda88 closed 1 month ago

Daeda88 commented 1 month ago

#

thoutbeckers commented 1 month ago

I've seen this test fail before these changes as well but maybe worth it to check out:

RecurringTimerTest > stateTransitions FAILED
    java.lang.AssertionError: Expected value to be true.
        at org.junit.Assert.fail(Assert.java:89)
        at kotlin.test.junit.JUnitAsserter.fail(JUnitSupport.kt:56)
        at kotlin.test.Asserter$DefaultImpls.assertTrue(Assertions.kt:694)
        at kotlin.test.junit.JUnitAsserter.assertTrue(JUnitSupport.kt:30)
        at kotlin.test.Asserter$DefaultImpls.assertTrue(Assertions.kt:704)
        at kotlin.test.junit.JUnitAsserter.assertTrue(JUnitSupport.kt:30)
        at kotlin.test.AssertionsKt__AssertionsKt.assertTrue(Assertions.kt:44)
        at kotlin.test.AssertionsKt.assertTrue(Unknown Source)
        at kotlin.test.AssertionsKt__AssertionsKt.assertTrue$default(Assertions.kt:42)
        at kotlin.test.AssertionsKt.assertTrue$default(Unknown Source)
        at com.splendo.kaluga.datetime.timer.RecurringTimerTest$stateTransitions$1.invokeSuspend(RecurringTimerTest.kt:51)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:99)
        at kotlinx.coroutines.EventLoopImplBase.processNextEvent(EventLoop.common.kt:263)
        at kotlinx.coroutines.BlockingCoroutine.joinBlocking(Builders.kt:95)
        at kotlinx.coroutines.BuildersKt__BuildersKt.runBlocking(Builders.kt:69)
        at kotlinx.coroutines.BuildersKt.runBlocking(Unknown Source)
        at com.splendo.kaluga.base.RunBlockingKt.runBlocking(runBlocking.kt:29)
        at com.splendo.kaluga.base.RunBlockingKt.runBlocking$default(runBlocking.kt:29)
        at com.splendo.kaluga.datetime.timer.RecurringTimerTest.stateTransitions(RecurringTimerTest.kt:41)
ci-splendo commented 1 month ago

Code coverage

File Coverage [93.02%]
date-time/src/commonMain/kotlin/com/splendo/kaluga/datetime/timer/RecurringTimer.kt 92.68%
date-time/src/commonMain/kotlin/com/splendo/kaluga/datetime/timer/Timer.kt 100.00%
Total Project Coverage 63.09%