test(naming): document bare-id trade-off; cover CJK title + movies numeric

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Silo Server Developer
2026-05-28 17:45:38 +02:00
co-authored by Claude Opus 4.7
parent cc7cd5cd39
commit a6da4a4a98
2 changed files with 15 additions and 0 deletions
+3
View File
@@ -69,6 +69,9 @@ func ParseFolderIDs(folderName string, folderType string) *FolderIDHints {
// A bare trailing number is only an ID when appended to a real title. If the
// name has no letters (e.g. "86", "22 7"), it's a numeric title, not an ID.
// Trade-off: a folder named ONLY a bare provider id (e.g. "81189") with no
// title text now returns nil rather than that id — acceptable because
// Sonarr/Radarr never produce bare-number folders.
if !containsLetter(trimmed) {
return nil
}
+12
View File
@@ -22,4 +22,16 @@ func TestParseFolderIDs_NumericTitleIsNotAnID(t *testing.T) {
if got == nil || got.TmdbID != "27205" {
t.Errorf(`ParseFolderIDs("{tmdb-27205}","movies") = %+v, want TmdbID="27205"`, got)
}
// Non-Latin (CJK) title with a trailing real id must still parse —
// unicode.IsLetter covers kana/kanji, so this is treated as title + id.
got = ParseFolderIDs("進撃の巨人 73743", "series")
if got == nil || got.TvdbID != "73743" {
t.Errorf(`ParseFolderIDs("進撃の巨人 73743","series") = %+v, want TvdbID="73743"`, got)
}
// Numeric-only title for a movies library is also not an id.
if got := ParseFolderIDs("86", "movies"); got != nil {
t.Errorf(`ParseFolderIDs("86","movies") = %+v, want nil`, got)
}
}