From: Matt Joiner Date: Thu, 17 Sep 2015 02:53:52 +0000 (+1000) Subject: Add a test for dropping a torrent before it gets the Info X-Git-Tag: v1.0.0~1041 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=afed0b7ce35a9b4c374f34032f1e5ffc475ad87b;p=btrtrc.git Add a test for dropping a torrent before it gets the Info Really just to check the behaviour doesn't change, it was mentioned before but wasn't the actual cause of any problem. --- diff --git a/client_test.go b/client_test.go index be387f78..fb797b2b 100644 --- a/client_test.go +++ b/client_test.go @@ -15,6 +15,7 @@ import ( _ "github.com/anacrolix/envpprof" "github.com/anacrolix/missinggo" + . "github.com/anacrolix/missinggo" "github.com/anacrolix/utp" "github.com/bradfitz/iter" "github.com/stretchr/testify/assert" @@ -587,3 +588,20 @@ func TestAddTorrentMetainfoInCache(t *testing.T) { // Obtained from the metainfo cache. require.NotNil(t, tt.Info()) } + +func TestTorrentDroppedBeforeGotInfo(t *testing.T) { + dir, mi := testutil.GreetingTestTorrent() + os.RemoveAll(dir) + cl, _ := NewClient(&TestingConfig) + defer cl.Close() + var ts TorrentSpec + CopyExact(&ts.InfoHash, mi.Info.Hash) + tt, _, _ := cl.AddTorrentSpec(&ts) + tt.Drop() + assert.EqualValues(t, 0, len(cl.Torrents())) + select { + case <-tt.GotInfo(): + t.FailNow() + default: + } +}