Добавил выбор из кандидатов, если LLM не уверена в раскладке
This commit is contained in:
@@ -159,6 +159,67 @@ func TestFileLinks_BatchLifecycle(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestCandidates_Lifecycle(t *testing.T) {
|
||||
st := newTestStore(t)
|
||||
ctx := context.Background()
|
||||
dl := seedDownload(t, st)
|
||||
recID, err := st.CreateRecognition(ctx, &Recognition{DownloadID: dl}, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("create recognition: %v", err)
|
||||
}
|
||||
|
||||
cands := []MetadataCandidate{
|
||||
{RecognitionID: recID, Provider: "tvdb", ProviderID: "269613",
|
||||
Title: NullString("Fargo"), Year: sql.NullInt64{Int64: 2014, Valid: true}},
|
||||
{RecognitionID: recID, Provider: "tmdb", ProviderID: "60622",
|
||||
Title: NullString("Fargo")},
|
||||
}
|
||||
if err := st.CreateCandidates(ctx, cands); err != nil {
|
||||
t.Fatalf("create candidates: %v", err)
|
||||
}
|
||||
|
||||
got, err := st.ListCandidatesByRecognition(ctx, recID)
|
||||
if err != nil {
|
||||
t.Fatalf("list: %v", err)
|
||||
}
|
||||
if len(got) != 2 || got[0].Provider != "tvdb" || got[0].ProviderID != "269613" {
|
||||
t.Fatalf("candidates = %+v", got)
|
||||
}
|
||||
|
||||
chosenID := got[0].ID
|
||||
if err := st.SetCandidateChosen(ctx, recID, chosenID); err != nil {
|
||||
t.Fatalf("set chosen: %v", err)
|
||||
}
|
||||
got, _ = st.ListCandidatesByRecognition(ctx, recID)
|
||||
for _, c := range got {
|
||||
want := c.ID == chosenID
|
||||
if c.Chosen != want {
|
||||
t.Errorf("candidate %d chosen = %v, want %v", c.ID, c.Chosen, want)
|
||||
}
|
||||
}
|
||||
|
||||
// GetCandidate + переотметка.
|
||||
single, err := st.GetCandidate(ctx, got[1].ID)
|
||||
if err != nil || single == nil || single.Provider != "tmdb" {
|
||||
t.Fatalf("get candidate = %+v, %v", single, err)
|
||||
}
|
||||
if err := st.SetCandidateChosen(ctx, recID, got[1].ID); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
got, _ = st.ListCandidatesByRecognition(ctx, recID)
|
||||
if got[0].Chosen || !got[1].Chosen {
|
||||
t.Errorf("re-choose failed: %+v", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetCandidate_None(t *testing.T) {
|
||||
st := newTestStore(t)
|
||||
c, err := st.GetCandidate(context.Background(), 999)
|
||||
if err != nil || c != nil {
|
||||
t.Errorf("want nil,nil; got %+v, %v", c, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestLatestBatchID_None(t *testing.T) {
|
||||
st := newTestStore(t)
|
||||
dl := seedDownload(t, st)
|
||||
|
||||
Reference in New Issue
Block a user