40 lines
1.5 KiB
Go
Executable File
40 lines
1.5 KiB
Go
Executable File
package registry_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"goyomi/internal/registry"
|
|
"goyomi/internal/source"
|
|
)
|
|
|
|
type mockSource struct {
|
|
id int64
|
|
name string
|
|
lang string
|
|
}
|
|
|
|
func (m *mockSource) ID() int64 { return m.id }
|
|
func (m *mockSource) Name() string { return m.name }
|
|
func (m *mockSource) Lang() string { return m.lang }
|
|
func (m *mockSource) SupportsLatest() bool { return false }
|
|
func (m *mockSource) GetPopularManga(page int) (source.MangasPage, error) { return source.MangasPage{}, nil }
|
|
func (m *mockSource) GetLatestUpdates(page int) (source.MangasPage, error) { return source.MangasPage{}, nil }
|
|
func (m *mockSource) GetSearchManga(page int, query string, filters []source.Filter) (source.MangasPage, error) {
|
|
return source.MangasPage{}, nil
|
|
}
|
|
func (m *mockSource) GetMangaDetails(manga source.SManga) (source.SManga, error) { return manga, nil }
|
|
func (m *mockSource) GetChapterList(manga source.SManga) ([]source.SChapter, error) { return nil, nil }
|
|
func (m *mockSource) GetPageList(chapter source.SChapter) ([]source.Page, error) { return nil, nil }
|
|
func (m *mockSource) GetImageURL(page source.Page) (string, error) { return page.ImageURL, nil }
|
|
func (m *mockSource) GetFilterList() []source.Filter { return nil }
|
|
|
|
func TestDuplicateIDPanics(t *testing.T) {
|
|
defer func() {
|
|
if r := recover(); r == nil {
|
|
t.Error("expected panic on duplicate source ID, got none")
|
|
}
|
|
}()
|
|
registry.Register(&mockSource{id: 9999, name: "A", lang: "en"})
|
|
registry.Register(&mockSource{id: 9999, name: "B", lang: "en"})
|
|
}
|