2
2
mirror of https://github.com/octoleo/restic.git synced 2024-06-01 00:20:48 +00:00

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

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)
}