diff --git a/temerity/src/commonMain/kotlin/edu/ucsc/its/temerity/Util.kt b/temerity/src/commonMain/kotlin/edu/ucsc/its/temerity/Util.kt index 3dd3c1d4cd82927de9110b62f03903842ab60b86..d4c36dc88ca2946ce633d7c28e90060a7ad32344 100644 --- a/temerity/src/commonMain/kotlin/edu/ucsc/its/temerity/Util.kt +++ b/temerity/src/commonMain/kotlin/edu/ucsc/its/temerity/Util.kt @@ -32,7 +32,7 @@ internal fun currentTz(): TimeZone = TimeZone.currentSystemDefault() internal fun thisInstant() = Clock.System.now() -internal fun currentDate(): LocalDate = Clock.System.todayIn(currentTz()) +public fun currentDate(): LocalDate = Clock.System.todayIn(currentTz()) internal fun currentTime(): LocalTime = thisInstant().toLocalDateTime(currentTz()).time diff --git a/temerity/src/jvmTest/kotlin/edu/ucsc/its/temerity/test/TemerityDevTest.kt b/temerity/src/jvmTest/kotlin/edu/ucsc/its/temerity/test/TemerityDevTest.kt index 097d4815cfeb93ff7465d47d8e4a59a92609171c..ebb5510d033c25c3e2fd05683486df89168c01e9 100644 --- a/temerity/src/jvmTest/kotlin/edu/ucsc/its/temerity/test/TemerityDevTest.kt +++ b/temerity/src/jvmTest/kotlin/edu/ucsc/its/temerity/test/TemerityDevTest.kt @@ -34,16 +34,12 @@ import io.kotest.core.spec.style.FunSpec import io.kotest.matchers.file.shouldNotBeEmpty import io.kotest.matchers.shouldBe import kotlinx.coroutines.runBlocking -import kotlinx.datetime.Clock import kotlinx.datetime.DateTimeUnit -import kotlinx.datetime.TimeZone import kotlinx.datetime.minus import kotlinx.datetime.plus -import kotlinx.datetime.todayIn import org.dotenv.vault.dotenvVault import org.jetbrains.kotlinx.dataframe.api.toDataFrame import org.jetbrains.kotlinx.dataframe.io.writeCSV -import org.koin.core.component.inject import org.koin.core.parameter.parametersOf import org.koin.test.KoinTest import java.io.File @@ -57,7 +53,7 @@ class TemerityDevTest : KoinTest { override fun extensions(): List<Extension> = listOf(koinExtension(loggerModule())) - private val kermit: Logger by inject { parametersOf("TemerityDevTest", TemClientConfig { supportKtxNotebook = false }) } + private lateinit var kermit: Logger init { val dotenv = dotenvVault() @@ -68,6 +64,7 @@ class TemerityDevTest : testTemerity = Temerity { configureDevEnvironment(dotenv) } + kermit = getKoin().get { parametersOf("TemerityDevTest", TemClientConfig { supportKtxNotebook = false }) } } test("Temerity client returns a correctly-formatted version String") { @@ -106,7 +103,7 @@ class TemerityDevTest : } test("Get all audit logs from the past month") { runBlocking { - val currentDate = Clock.System.todayIn(TimeZone.currentSystemDefault()) + val currentDate = currentDate() val pastDate = currentDate.minus(1, DateTimeUnit.MONTH) val logs = testTemerity.getAuditLogEntries(pastDate, currentDate, sortOrder = NEW_FIRST) println("Returned events from the past month:") @@ -116,7 +113,7 @@ class TemerityDevTest : } test("Get all audit logs from the past day") { runBlocking { - val currentDate = Clock.System.todayIn(TimeZone.currentSystemDefault()) + val currentDate = currentDate() val pastDate = currentDate.minus(1, DateTimeUnit.DAY) val logs = testTemerity.getAuditLogEntries(pastDate, currentDate, sortOrder = NEW_FIRST) Logger.d("Returned events from the past day:") @@ -126,7 +123,7 @@ class TemerityDevTest : } test("Get all recording sessions belonging to a single user scheduled for the next week") { runBlocking { - val pastDate = Clock.System.todayIn(TimeZone.currentSystemDefault()).minus(1, DateTimeUnit.DAY) + val pastDate = currentDate().minus(1, DateTimeUnit.DAY) val futureDate = pastDate.plus(1, DateTimeUnit.MONTH) val sessions = testTemerity.getUserSessions("dotenv[YUJADEV_TEST_USER]", pastDate, futureDate) Logger.d("Returned sessions for the next week:") @@ -153,7 +150,7 @@ class TemerityDevTest : test("Get all recording sessions on a single device scheduled for the next week") { runBlocking { - val pastDate = Clock.System.todayIn(TimeZone.currentSystemDefault()).minus(1, DateTimeUnit.DAY) + val pastDate = currentDate().minus(1, DateTimeUnit.DAY) val futureDate = pastDate.plus(1, DateTimeUnit.MONTH) val testDeviceId = dotenv["YUJADEV_TEST_DEVICE_ID"].toLongOrNull() val sessions = testTemerity.getDeviceSchedule(testDeviceId!!, pastDate, futureDate) @@ -167,7 +164,7 @@ class TemerityDevTest : test("Get all audit log entries of type \"New Login\" from the past day") { runBlocking { val testEventType = NEW_LOG_IN - val currentDate = Clock.System.todayIn(TimeZone.currentSystemDefault()) + val currentDate = currentDate() val pastDate = currentDate.minus(1, DateTimeUnit.DAY) val returnedAuditLogEntries = testTemerity.getAuditLogEntries(