]> Sergey Matveev's repositories - btrtrc.git/blob - issue97_test.go
Add test for issue #97
[btrtrc.git] / issue97_test.go
1 package torrent
2
3 import (
4         "io/ioutil"
5         "os"
6         "testing"
7
8         "github.com/stretchr/testify/require"
9
10         "github.com/anacrolix/torrent/internal/testutil"
11         "github.com/anacrolix/torrent/storage"
12 )
13
14 func TestHashPieceAfterStorageClosed(t *testing.T) {
15         td, err := ioutil.TempDir("", "")
16         require.NoError(t, err)
17         defer os.RemoveAll(td)
18         cs := storage.NewFile(td)
19         tt := &Torrent{}
20         tt.info = &testutil.GreetingMetaInfo().Info
21         tt.makePieces()
22         tt.storage, err = cs.OpenTorrent(tt.info)
23         require.NoError(t, err)
24         require.NoError(t, tt.storage.Close())
25         tt.hashPiece(0)
26 }