Only prune torrents if they have no peers

This commit is contained in:
Justin Li
2014-07-16 14:11:01 -04:00
parent 5f4f63cc44
commit e29fb21edb
3 changed files with 14 additions and 3 deletions

View File

@@ -78,7 +78,15 @@ func TestTorrentPurging(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if status != http.StatusOK {
t.Fatalf("expected torrent to exist (got %s)", http.StatusText(status))
}
time.Sleep(1010 * time.Millisecond)
_, status, err = fetchPath(torrentApiPath)
if err != nil {
t.Fatal(err)
}
if status != http.StatusOK {
t.Fatalf("expected torrent to exist (got %s)", http.StatusText(status))
}
@@ -88,13 +96,12 @@ func TestTorrentPurging(t *testing.T) {
peer["event"] = "stopped"
announce(peer, srv)
time.Sleep(1000 * time.Millisecond)
time.Sleep(1010 * time.Millisecond)
_, status, err = fetchPath(torrentApiPath)
if err != nil {
t.Fatal(err)
}
if status != http.StatusNotFound {
t.Fatalf("expected torrent to have been purged (got %s)", http.StatusText(status))
}