Добавил логи
This commit is contained in:
@@ -38,7 +38,7 @@ func TestIntegration_RecognizeSeries(t *testing.T) {
|
||||
provider, err := llm.New(llm.Config{
|
||||
Type: "openai-compat", BaseURL: base, APIKey: key, Model: model,
|
||||
Timeout: 90 * time.Second,
|
||||
})
|
||||
}, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("llm.New: %v", err)
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
func parsePlan(raw string, in Input) (Plan, error) {
|
||||
jsonStr, err := llm.ExtractJSONObject(raw)
|
||||
if err != nil {
|
||||
return Plan{}, fmt.Errorf("в ответе нет JSON-объекта")
|
||||
return Plan{}, fmt.Errorf("no JSON object in response")
|
||||
}
|
||||
|
||||
var p Plan
|
||||
@@ -25,7 +25,7 @@ func parsePlan(raw string, in Input) (Plan, error) {
|
||||
// Повторяем без строгого режима: лишние поля — не повод падать,
|
||||
// но если и так не разобралось — это ошибка схемы.
|
||||
if err2 := json.Unmarshal([]byte(jsonStr), &p); err2 != nil {
|
||||
return Plan{}, fmt.Errorf("JSON не разобран: %v", err2)
|
||||
return Plan{}, fmt.Errorf("JSON not parsed: %v", err2)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,15 +42,15 @@ func validateSchema(p *Plan, in Input) error {
|
||||
switch p.Type {
|
||||
case MediaMovie, MediaSeries:
|
||||
case "":
|
||||
return fmt.Errorf("поле type пустое (ожидалось movie или series)")
|
||||
return fmt.Errorf("field type is empty (expected movie or series)")
|
||||
default:
|
||||
return fmt.Errorf("неизвестный type %q", p.Type)
|
||||
return fmt.Errorf("unknown type %q", p.Type)
|
||||
}
|
||||
if strings.TrimSpace(p.Title) == "" {
|
||||
return fmt.Errorf("поле title пустое")
|
||||
return fmt.Errorf("field title is empty")
|
||||
}
|
||||
if len(p.Files) == 0 {
|
||||
return fmt.Errorf("список files пуст")
|
||||
return fmt.Errorf("files list is empty")
|
||||
}
|
||||
|
||||
known := make(map[string]bool, len(in.Files))
|
||||
@@ -61,16 +61,16 @@ func validateSchema(p *Plan, in Input) error {
|
||||
for i := range p.Files {
|
||||
pf := &p.Files[i]
|
||||
if !pf.Role.valid() {
|
||||
return fmt.Errorf("файл %q: неизвестная role %q", pf.Src, pf.Role)
|
||||
return fmt.Errorf("file %q: unknown role %q", pf.Src, pf.Role)
|
||||
}
|
||||
if strings.TrimSpace(pf.Src) == "" {
|
||||
return fmt.Errorf("файл с пустым src")
|
||||
return fmt.Errorf("file with empty src")
|
||||
}
|
||||
if !known[pf.Src] {
|
||||
return fmt.Errorf("src %q не найден среди файлов торрента", pf.Src)
|
||||
return fmt.Errorf("src %q not found among torrent files", pf.Src)
|
||||
}
|
||||
if pf.Role == RoleEpisode && pf.Episode == nil {
|
||||
return fmt.Errorf("серия %q без номера episode", pf.Src)
|
||||
return fmt.Errorf("episode %q has no episode number", pf.Src)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -37,14 +37,14 @@ func TestValidateSchema_Errors(t *testing.T) {
|
||||
p Plan
|
||||
want string
|
||||
}{
|
||||
{"empty type", Plan{Title: "x", Files: []PlanFile{{Src: "a.mkv", Role: RoleMain}}}, "type пустое"},
|
||||
{"bad type", Plan{Type: "show", Title: "x", Files: []PlanFile{{Src: "a.mkv", Role: RoleMain}}}, "неизвестный type"},
|
||||
{"empty title", Plan{Type: MediaMovie, Files: []PlanFile{{Src: "a.mkv", Role: RoleMain}}}, "title пустое"},
|
||||
{"no files", Plan{Type: MediaMovie, Title: "x"}, "files пуст"},
|
||||
{"bad role", Plan{Type: MediaMovie, Title: "x", Files: []PlanFile{{Src: "a.mkv", Role: "boss"}}}, "неизвестная role"},
|
||||
{"empty src", Plan{Type: MediaMovie, Title: "x", Files: []PlanFile{{Src: "", Role: RoleMain}}}, "пустым src"},
|
||||
{"unknown src", Plan{Type: MediaMovie, Title: "x", Files: []PlanFile{{Src: "z.mkv", Role: RoleMain}}}, "не найден"},
|
||||
{"episode no num", Plan{Type: MediaSeries, Title: "x", Files: []PlanFile{{Src: "a.mkv", Role: RoleEpisode, Season: intp(1)}}}, "без номера episode"},
|
||||
{"empty type", Plan{Title: "x", Files: []PlanFile{{Src: "a.mkv", Role: RoleMain}}}, "type is empty"},
|
||||
{"bad type", Plan{Type: "show", Title: "x", Files: []PlanFile{{Src: "a.mkv", Role: RoleMain}}}, "unknown type"},
|
||||
{"empty title", Plan{Type: MediaMovie, Files: []PlanFile{{Src: "a.mkv", Role: RoleMain}}}, "title is empty"},
|
||||
{"no files", Plan{Type: MediaMovie, Title: "x"}, "files list is empty"},
|
||||
{"bad role", Plan{Type: MediaMovie, Title: "x", Files: []PlanFile{{Src: "a.mkv", Role: "boss"}}}, "unknown role"},
|
||||
{"empty src", Plan{Type: MediaMovie, Title: "x", Files: []PlanFile{{Src: "", Role: RoleMain}}}, "empty src"},
|
||||
{"unknown src", Plan{Type: MediaMovie, Title: "x", Files: []PlanFile{{Src: "z.mkv", Role: RoleMain}}}, "not found among torrent files"},
|
||||
{"episode no num", Plan{Type: MediaSeries, Title: "x", Files: []PlanFile{{Src: "a.mkv", Role: RoleEpisode, Season: intp(1)}}}, "has no episode number"},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user