Files
AudioManager/src/test/kotlin/win/taptap/musicmanager/config/AppConfigTest.kt
T
TapTap bf6c9e7394
CI / chart (push) Successful in 3s
CI / chart-push (push) Successful in 3s
CI / test (push) Successful in 1m53s
CI / image (push) Successful in 4m12s
refactor: remove the server-rendered web UI
All browsing and mood management now live in the native client. Drop the
embedded HTML page, the WEB_UI setting, the /ui route and the chart env
entry; the server only exposes /api/v1, /health and a small root banner.
2026-11-14 19:36:43 +00:00

51 lines
1.7 KiB
Kotlin

package win.taptap.musicmanager.config
import java.nio.file.Path
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFailsWith
class AppConfigTest {
@Test
fun `uses documented defaults`() {
val config = AppConfig.fromEnv(emptyMap())
assertEquals(8080, config.port)
assertEquals(Path.of("./data"), config.dataDir)
assertEquals(Path.of("./config/library.yaml"), config.libraryConfigPath)
assertEquals(Path.of("./config/users.yaml"), config.usersFile)
assertEquals("ffmpeg", config.ffmpegPath)
assertEquals(Path.of("./data/musicmanager.db"), config.databasePath)
}
@Test
fun `reads overrides from the environment`() {
val config = AppConfig.fromEnv(
mapOf(
"PORT" to "9090",
"DATA_DIR" to "/var/lib/musicmanager",
"LIBRARY_CONFIG" to "/etc/musicmanager/library.yaml",
"USERS_FILE" to "/run/secrets/users.yaml",
"FFMPEG_PATH" to "/usr/bin/ffmpeg",
),
)
assertEquals(9090, config.port)
assertEquals(Path.of("/var/lib/musicmanager"), config.dataDir)
assertEquals(Path.of("/etc/musicmanager/library.yaml"), config.libraryConfigPath)
assertEquals(Path.of("/run/secrets/users.yaml"), config.usersFile)
assertEquals("/usr/bin/ffmpeg", config.ffmpegPath)
}
@Test
fun `rejects a malformed port`() {
assertFailsWith<IllegalArgumentException> {
AppConfig.fromEnv(mapOf("PORT" to "not-a-number"))
}
assertFailsWith<IllegalArgumentException> {
AppConfig.fromEnv(mapOf("PORT" to "70000"))
}
}
}