Skip to content
Snippets Groups Projects
Commit 94407f27 authored by William Walker's avatar William Walker
Browse files

logger injection fail; blocked by koin 4.0.1 fix

-Move logger injection to init block, after Koin context should've already been created
-Simplify client test
-Expose utility fun to get current date
parent c901e20e
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment