Files
silo-server/internal/naming/folderid_numeric_test.go
T
Silo Server DeveloperandClaude Opus 4.7 534f7bb901 fix(naming): numeric-only titles are not bare provider IDs
'86' / '22 7' were parsed as trailing tvdb ids, tripping the trusted-ID gate
so the correct title match was rejected. Require a letter in the name before
treating a trailing number as a bare id.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-28 17:45:38 +02:00

26 lines
923 B
Go

package naming
import "testing"
func TestParseFolderIDs_NumericTitleIsNotAnID(t *testing.T) {
// Numeric-only anime titles must NOT be parsed as a bare trailing tvdb/tmdb id.
if got := ParseFolderIDs("86", "series"); got != nil {
t.Errorf(`ParseFolderIDs("86","series") = %+v, want nil`, got)
}
if got := ParseFolderIDs("22 7", "series"); got != nil {
t.Errorf(`ParseFolderIDs("22 7","series") = %+v, want nil`, got)
}
// A real bare trailing id with title text must still be parsed.
got := ParseFolderIDs("Some Show 81189", "series")
if got == nil || got.TvdbID != "81189" {
t.Errorf(`ParseFolderIDs("Some Show 81189","series") = %+v, want TvdbID="81189"`, got)
}
// Structured tags must still win regardless of letters.
got = ParseFolderIDs("{tmdb-27205}", "movies")
if got == nil || got.TmdbID != "27205" {
t.Errorf(`ParseFolderIDs("{tmdb-27205}","movies") = %+v, want TmdbID="27205"`, got)
}
}