10 "github.com/anacrolix/missinggo/v2"
11 "github.com/stretchr/testify/assert"
12 "github.com/stretchr/testify/require"
14 "github.com/anacrolix/torrent/metainfo"
17 func TestShortFile(t *testing.T) {
21 info := &metainfo.Info{
24 PieceLength: missinggo.MiB,
26 ts, err := s.OpenTorrent(info, metainfo.Hash{})
27 assert.NoError(t, err)
28 f, err := os.Create(filepath.Join(td, "a"))
29 require.NoError(t, err)
31 require.NoError(t, err)
35 n, err := io.Copy(&buf, io.NewSectionReader(ts.Piece(p), 0, p.Length()))
36 assert.EqualValues(t, 1, n)
40 t.Errorf("expected nil or EOF error from truncated piece, got %v", err)