]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Add a test for dropping a torrent before it gets the Info
authorMatt Joiner <anacrolix@gmail.com>
Thu, 17 Sep 2015 02:53:52 +0000 (12:53 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Thu, 17 Sep 2015 02:53:52 +0000 (12:53 +1000)
Really just to check the behaviour doesn't change, it was mentioned before but wasn't the actual cause of any problem.

client_test.go

index be387f78712d907d79c6eda9f04a25d88167685f..fb797b2bb9607e1f30602d028a6f202b14495bac 100644 (file)
@@ -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:
+       }
+}