- V9 adds source/external_id to songs, moods, recommendations and jobs - Deezer public catalog for search, related album covers and metadata - streamrip downloader configured with DEEZER_ARL, 128/320 MP3 - per-mood source selector; switching clears and refills recommendations - keep YouTube Music as a full second catalog and downloader - media layout <source>-<externalId>, legacy YouTube folders still read - Docker/streamrip install, chart ARL secret, docs and dual-source smoke test
44 lines
1.4 KiB
Kotlin
44 lines
1.4 KiB
Kotlin
package win.taptap.musicmanager.util
|
|
|
|
import kotlin.test.Test
|
|
import kotlin.test.assertEquals
|
|
import kotlin.test.assertNotEquals
|
|
import kotlin.test.assertTrue
|
|
|
|
class IdGeneratorTest {
|
|
|
|
@Test
|
|
fun `normalization is NFC, trimmed, collapsed and lowercase`() {
|
|
val decomposed = "Cafe\u0301 The Artist"
|
|
assertEquals("café the artist", IdGenerator.normalize(decomposed))
|
|
assertEquals(IdGenerator.normalize(" THE Artist "), IdGenerator.normalize("the artist"))
|
|
}
|
|
|
|
@Test
|
|
fun `song IDs are deterministic, prefixed and 24 hex characters`() {
|
|
val first = IdGenerator.songId("youtube", "dQw4w9WgXcQ")
|
|
val second = IdGenerator.songId("youtube", " dQw4w9WgXcQ ")
|
|
|
|
assertEquals(first, second)
|
|
assertTrue(first.startsWith("sg-"))
|
|
assertEquals(27, first.length)
|
|
}
|
|
|
|
@Test
|
|
fun `different videos produce different IDs`() {
|
|
assertNotEquals(
|
|
IdGenerator.songId("youtube", "dQw4w9WgXcQ"),
|
|
IdGenerator.songId("youtube", "dQw4w9WgXcR"),
|
|
)
|
|
}
|
|
|
|
@Test
|
|
fun `mood IDs are deterministic for the same inputs`() {
|
|
val id = IdGenerator.moodId("Alice", "Focus", "2026-01-01T00:00:00Z")
|
|
|
|
assertTrue(id.startsWith("mo-"))
|
|
assertEquals(id, IdGenerator.moodId("alice", " Focus ", "2026-01-01T00:00:00Z"))
|
|
assertNotEquals(id, IdGenerator.moodId("Alice", "Focus", "2026-01-02T00:00:00Z"))
|
|
}
|
|
}
|