Files
2026-05-11 06:48:23 +00:00

29 lines
689 B
Go
Executable File

package source_test
import (
"testing"
"goyomi/internal/source"
)
func TestGenerateSourceID(t *testing.T) {
// IDs computed from the same MD5 formula as Tachiyomi/Suwayomi HttpSource.generateId:
// key = "${name.lowercase()}/$lang/1", MD5 → first 8 bytes big-endian, sign bit cleared.
cases := []struct {
name string
lang string
want int64
}{
{"MangaDex", "en", 2499283573021220255},
{"MangaDex", "all", 6404943692147160087},
{"HeanCms", "en", 6473152836656709188},
}
for _, tc := range cases {
got := source.GenerateSourceID(tc.name, tc.lang)
if got != tc.want {
t.Errorf("GenerateSourceID(%q, %q) = %d, want %d", tc.name, tc.lang, got, tc.want)
}
}
}