From 34fbadaf0da365abc534e96069f773ab9e807942 Mon Sep 17 00:00:00 2001 From: starry-shivam Date: Thu, 20 Jun 2024 12:09:11 +0530 Subject: [PATCH] Fix wrong assertion Signed-off-by: starry-shivam --- .../kotlin/dev/starry/ktscheduler/KtSchedulerTest.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/test/kotlin/dev/starry/ktscheduler/KtSchedulerTest.kt b/src/test/kotlin/dev/starry/ktscheduler/KtSchedulerTest.kt index 8c8ef95..9631584 100644 --- a/src/test/kotlin/dev/starry/ktscheduler/KtSchedulerTest.kt +++ b/src/test/kotlin/dev/starry/ktscheduler/KtSchedulerTest.kt @@ -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(