]> Sergey Matveev's repositories - btrtrc.git/blob - issue211_test.go
Switch to goimports import sorting
[btrtrc.git] / issue211_test.go
1 package torrent
2
3 import (
4         "io"
5         "io/ioutil"
6         "testing"
7
8         "github.com/anacrolix/torrent/internal/testutil"
9         "github.com/anacrolix/torrent/storage"
10         "github.com/stretchr/testify/assert"
11         "github.com/stretchr/testify/require"
12         "golang.org/x/time/rate"
13 )
14
15 func TestDropTorrentWithMmapStorageWhileHashing(t *testing.T) {
16         cfg := TestingConfig()
17         // Ensure the data is present when the torrent is added, and not obtained
18         // over the network as the test runs.
19         cfg.DownloadRateLimiter = rate.NewLimiter(0, 0)
20         cl, err := NewClient(cfg)
21         require.NoError(t, err)
22         defer cl.Close()
23
24         td, mi := testutil.GreetingTestTorrent()
25         tt, new, err := cl.AddTorrentSpec(&TorrentSpec{
26                 Storage:   storage.NewMMap(td),
27                 InfoHash:  mi.HashInfoBytes(),
28                 InfoBytes: mi.InfoBytes,
29         })
30         require.NoError(t, err)
31         assert.True(t, new)
32
33         r := tt.NewReader()
34         go tt.Drop()
35         io.Copy(ioutil.Discard, r)
36 }