Фикс не найденного торрента при ревью
This commit is contained in:
@@ -344,6 +344,42 @@ func TestRecognizeOne_CompletedToReview(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestRecognizeOne_FindsTagAdoptedTorrent — регрессия: раздача, усыновлённая
|
||||
// по тегу, имеет чужую (или пустую) категорию. Поиск по infohash при
|
||||
// распознавании обязан её найти; раньше фильтр по w.cfg.Category её терял и
|
||||
// распознавание падало с «torrent not found in qBittorrent».
|
||||
func TestRecognizeOne_FindsTagAdoptedTorrent(t *testing.T) {
|
||||
st := newMemStore()
|
||||
st.put(completedDownload(1))
|
||||
qb := &fakeQbt{
|
||||
torrents: []qbt.Torrent{{
|
||||
Hash: ihTest, Name: "ThePitt", SavePath: "/d",
|
||||
Category: "movies", Tags: "jellybit", // тег наш, категория чужая
|
||||
}},
|
||||
files: []qbt.File{{Name: "ThePitt/e1.mkv", Size: 100}, {Name: "ThePitt/e2.mkv", Size: 100}},
|
||||
}
|
||||
rec := &fakeRecognizer{result: seriesResult()}
|
||||
w := testWorkerWith(st, qb, rec, nil)
|
||||
|
||||
w.recognizeOne(context.Background(), 1)
|
||||
|
||||
if st.downloads[1].State != store.StateReview {
|
||||
t.Fatalf("state = %q, want review", st.downloads[1].State)
|
||||
}
|
||||
// Recognizer вернул бы Title="Show" только если торрент найден по infohash;
|
||||
// при потере (фильтр по категории) был бы пустой план с причиной «not found».
|
||||
cur, _ := st.GetCurrentRecognition(context.Background(), 1)
|
||||
if cur == nil || cur.Title.String != "Show" {
|
||||
t.Fatalf("recognizer did not run on found torrent (title=%q): torrent must be found by infohash despite foreign category",
|
||||
func() string {
|
||||
if cur == nil {
|
||||
return "<nil>"
|
||||
}
|
||||
return cur.Title.String
|
||||
}())
|
||||
}
|
||||
}
|
||||
|
||||
func TestRecognizeOne_DiscardsWhenStateChanged(t *testing.T) {
|
||||
st := newMemStore()
|
||||
st.put(completedDownload(1))
|
||||
|
||||
Reference in New Issue
Block a user