Добавил еще провайдер TVMaze
This commit is contained in:
@@ -9,6 +9,45 @@ import (
|
||||
"git.vakhrushev.me/av/jellybit/internal/metadata"
|
||||
)
|
||||
|
||||
// TestIntegration_TVMaze бьётся в реальный TVMaze (без ключа). Сетевой, по
|
||||
// умолчанию пропускается; включается флагом:
|
||||
//
|
||||
// JELLYBIT_LIVE=1 go test ./internal/metadata/ -run Integration -v
|
||||
func TestIntegration_TVMaze(t *testing.T) {
|
||||
if os.Getenv("JELLYBIT_LIVE") == "" {
|
||||
t.Skip("set JELLYBIT_LIVE=1 to run network tests")
|
||||
}
|
||||
c, err := metadata.NewTVMaze(metadata.TVMazeConfig{Timeout: 20 * time.Second})
|
||||
if err != nil {
|
||||
t.Fatalf("NewTVMaze: %v", err)
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
cands, err := c.Search(ctx, metadata.Query{Type: metadata.Series, Title: "Fargo", Year: 2014})
|
||||
if err != nil {
|
||||
t.Fatalf("Search: %v", err)
|
||||
}
|
||||
if len(cands) == 0 {
|
||||
t.Fatal("ожидался хотя бы один кандидат")
|
||||
}
|
||||
top := cands[0]
|
||||
t.Logf("top: id=%s title=%q year=%d tag=%s/%s",
|
||||
top.ID, top.Title, top.Year, top.TagProvider, top.TagID)
|
||||
if top.TagProvider != "tvdb" || top.TagID == "" {
|
||||
t.Errorf("ожидался TVDB-тег из externals, got %s/%s", top.TagProvider, top.TagID)
|
||||
}
|
||||
|
||||
counts, err := c.SeasonEpisodeCounts(ctx, top.ID)
|
||||
if err != nil {
|
||||
t.Fatalf("SeasonEpisodeCounts: %v", err)
|
||||
}
|
||||
t.Logf("season counts: %v", counts)
|
||||
if counts[1] == 0 {
|
||||
t.Error("ожидались серии в первом сезоне")
|
||||
}
|
||||
}
|
||||
|
||||
// TestIntegration_TVDB бьётся в реальный TheTVDB v4. По умолчанию
|
||||
// пропускается; включается ключом:
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user