feat: bootstrap MusicManager with scanner and Subsonic auth
- Gradle/Kotlin/Ktor project on JVM 21 with ShadowJar - SQLite WAL, Flyway migrations and config-driven users/folders - deterministic IDs, MP3 tag extraction, cover cache and delta scanner - OpenSubsonic JSON envelope with token/password authentication - system endpoints: ping, license, extensions, scan status
This commit is contained in:
1 parent
961341b449
commit
e194badefb
45 files changed
+4079
-126
No files matched your search
@@ -0,0 +1,50 @@
|
||||
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"))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user