11 "github.com/anacrolix/missinggo"
12 "github.com/stretchr/testify/assert"
13 "github.com/stretchr/testify/require"
15 "github.com/anacrolix/torrent/metainfo"
18 func TestShortFile(t *testing.T) {
19 td, err := ioutil.TempDir("", "")
20 require.NoError(t, err)
21 defer os.RemoveAll(td)
23 info := &metainfo.Info{
26 PieceLength: missinggo.MiB,
28 f, err := os.Create(filepath.Join(td, "a"))
33 n, err := io.Copy(&buf, io.NewSectionReader(data.Piece(p), 0, p.Length()))
34 assert.EqualValues(t, 1, n)
35 assert.Equal(t, io.ErrUnexpectedEOF, err)