Добавил "усыновление" существующих торрентов при добавлении тега или
категории
This commit is contained in:
@@ -212,6 +212,30 @@ func TestCandidates_Lifecycle(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestExistsByInfohash(t *testing.T) {
|
||||
st := newTestStore(t)
|
||||
ctx := context.Background()
|
||||
const ih = "aabbccddeeff00112233445566778899aabbccdd"
|
||||
|
||||
exists, err := st.ExistsByInfohash(ctx, ih)
|
||||
if err != nil || exists {
|
||||
t.Fatalf("пусто: exists=%v err=%v", exists, err)
|
||||
}
|
||||
if _, err := st.CreateDownload(ctx, newDownloading(ih)); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
exists, err = st.ExistsByInfohash(ctx, ih)
|
||||
if err != nil || !exists {
|
||||
t.Fatalf("после вставки: exists=%v err=%v", exists, err)
|
||||
}
|
||||
// Терминальное состояние тоже считается «видели» (не реусыновляем).
|
||||
id, _ := st.CreateDownload(ctx, newDownloading("ffffffffffffffffffffffffffffffffffffffff"))
|
||||
_ = st.SetDownloadState(ctx, id, StateDone, "", "")
|
||||
if ex, _ := st.ExistsByInfohash(ctx, "ffffffffffffffffffffffffffffffffffffffff"); !ex {
|
||||
t.Error("done-задача должна считаться существующей")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetCandidate_None(t *testing.T) {
|
||||
st := newTestStore(t)
|
||||
c, err := st.GetCandidate(context.Background(), 999)
|
||||
|
||||
Reference in New Issue
Block a user