Skip to content

Commit

Permalink
Fix wrong assertion
Browse files Browse the repository at this point in the history
Signed-off-by: starry-shivam <[email protected]>
  • Loading branch information
starry-shivam committed Jun 20, 2024
1 parent ce6624d commit 34fbada
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/test/kotlin/dev/starry/ktscheduler/KtSchedulerTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -301,19 +301,20 @@ class KtSchedulerTest {
nextRunTime = ZonedDateTime.now().plusSeconds(1),
callback = { delay(2000) }
)

val eventListener = TestJobEventListener()

scheduler.addJob(job)
scheduler.addEventListener(eventListener)
scheduler.start()
Thread.sleep(200)
// Job should not be completed yet
assertEquals(0, eventListener.completedJobs.size)
// Wait for enough time to ensure job has run
Thread.sleep(3200)
Thread.sleep(3000)
scheduler.shutdown()
// Assert that the job was only executed once
assertEquals(1, eventListener.completedJobs.size)
// Assert that the job is rescheduled
assertEquals(scheduler.getJob("longRunningJob")?.nextRunTime, ZonedDateTime.now().plusSeconds(1))
assertEquals("longRunningJob", eventListener.completedJobs[0])
}

private fun createTestJob(
Expand Down

0 comments on commit 34fbada

Please sign in to comment.