2022-06-15 06:40:03 +00:00
|
|
|
package dev.inmo.krontab.utils
|
|
|
|
|
2022-06-15 07:27:21 +00:00
|
|
|
import com.soywiz.klock.DateTime
|
|
|
|
import com.soywiz.klock.days
|
2022-06-15 06:40:03 +00:00
|
|
|
import dev.inmo.krontab.buildSchedule
|
2023-03-18 06:23:53 +00:00
|
|
|
import kotlinx.coroutines.test.runTest
|
2022-06-15 07:27:21 +00:00
|
|
|
import kotlin.test.*
|
2022-06-15 06:40:03 +00:00
|
|
|
|
2022-06-15 08:43:28 +00:00
|
|
|
class CheckMonthsAndDaysCorrectWork {
|
2022-06-15 06:40:03 +00:00
|
|
|
@Test
|
2022-06-15 08:43:28 +00:00
|
|
|
fun checkMonthsAndDaysCorrectWork() {
|
2022-06-15 07:27:21 +00:00
|
|
|
val now = DateTime.now().startOfYear.startOfDay
|
|
|
|
for (i in 0 until now.year.days) {
|
|
|
|
val scheduleDateTime = (now + i.days)
|
|
|
|
runTest {
|
|
|
|
assertEquals(
|
|
|
|
scheduleDateTime,
|
|
|
|
buildSchedule("0 0 0 ${scheduleDateTime.dayOfMonth - 1} ${scheduleDateTime.month0}").next(now)
|
|
|
|
)
|
|
|
|
}
|
2022-06-15 06:40:03 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|