backend tests load: Use reader with Size() method

This commit is contained in:
Alexander Neumann 2017-05-13 19:56:11 +02:00
parent c7209ef231
commit 4ac0d3ad40
1 changed files with 7 additions and 2 deletions

View File

@ -277,7 +277,8 @@ func BackendTestLoad(t testing.TB, s *Suite) {
type errorCloser struct {
io.Reader
t testing.TB
size int64
t testing.TB
}
func (ec errorCloser) Close() error {
@ -285,6 +286,10 @@ func (ec errorCloser) Close() error {
return errors.New("forbidden method close was called")
}
func (ec errorCloser) Size() int64 {
return ec.size
}
// BackendTestSave tests saving data in the backend.
func BackendTestSave(t testing.TB, s *Suite) {
b := s.open(t)
@ -354,7 +359,7 @@ func BackendTestSave(t testing.TB, s *Suite) {
// wrap the tempfile in an errorCloser, so we can detect if the backend
// closes the reader
err = b.Save(h, errorCloser{t: t, Reader: tmpfile})
err = b.Save(h, errorCloser{t: t, size: int64(length), Reader: tmpfile})
if err != nil {
t.Fatal(err)
}