Add success callback to the backend
This commit is contained in:
parent
baf58fbaa8
commit
be6baaec12
3 changed files with 33 additions and 20 deletions
|
@ -35,7 +35,7 @@ func TestBackendSaveRetry(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
retryBackend := NewRetryBackend(be, 10, nil)
|
||||
retryBackend := NewRetryBackend(be, 10, nil, nil)
|
||||
|
||||
data := test.Random(23, 5*1024*1024+11241)
|
||||
err := retryBackend.Save(context.TODO(), restic.Handle{}, restic.NewByteReader(data, be.Hasher()))
|
||||
|
@ -70,7 +70,7 @@ func TestBackendSaveRetryAtomic(t *testing.T) {
|
|||
HasAtomicReplaceFn: func() bool { return true },
|
||||
}
|
||||
|
||||
retryBackend := NewRetryBackend(be, 10, nil)
|
||||
retryBackend := NewRetryBackend(be, 10, nil, nil)
|
||||
|
||||
data := test.Random(23, 5*1024*1024+11241)
|
||||
err := retryBackend.Save(context.TODO(), restic.Handle{}, restic.NewByteReader(data, be.Hasher()))
|
||||
|
@ -103,7 +103,7 @@ func TestBackendListRetry(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
retryBackend := NewRetryBackend(be, 10, nil)
|
||||
retryBackend := NewRetryBackend(be, 10, nil, nil)
|
||||
|
||||
var listed []string
|
||||
err := retryBackend.List(context.TODO(), restic.PackFile, func(fi restic.FileInfo) error {
|
||||
|
@ -132,7 +132,7 @@ func TestBackendListRetryErrorFn(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
retryBackend := NewRetryBackend(be, 10, nil)
|
||||
retryBackend := NewRetryBackend(be, 10, nil, nil)
|
||||
|
||||
var ErrTest = errors.New("test error")
|
||||
|
||||
|
@ -188,7 +188,7 @@ func TestBackendListRetryErrorBackend(t *testing.T) {
|
|||
}
|
||||
|
||||
const maxRetries = 2
|
||||
retryBackend := NewRetryBackend(be, maxRetries, nil)
|
||||
retryBackend := NewRetryBackend(be, maxRetries, nil, nil)
|
||||
|
||||
var listed []string
|
||||
err := retryBackend.List(context.TODO(), restic.PackFile, func(fi restic.FileInfo) error {
|
||||
|
@ -257,7 +257,7 @@ func TestBackendLoadRetry(t *testing.T) {
|
|||
return failingReader{data: data, limit: limit}, nil
|
||||
}
|
||||
|
||||
retryBackend := NewRetryBackend(be, 10, nil)
|
||||
retryBackend := NewRetryBackend(be, 10, nil, nil)
|
||||
|
||||
var buf []byte
|
||||
err := retryBackend.Load(context.TODO(), restic.Handle{}, 0, 0, func(rd io.Reader) (err error) {
|
||||
|
@ -276,7 +276,7 @@ func assertIsCanceled(t *testing.T, err error) {
|
|||
func TestBackendCanceledContext(t *testing.T) {
|
||||
// unimplemented mock backend functions return an error by default
|
||||
// check that we received the expected context canceled error instead
|
||||
retryBackend := NewRetryBackend(mock.NewBackend(), 2, nil)
|
||||
retryBackend := NewRetryBackend(mock.NewBackend(), 2, nil, nil)
|
||||
h := restic.Handle{Type: restic.PackFile, Name: restic.NewRandomID().String()}
|
||||
|
||||
// create an already canceled context
|
||||
|
@ -313,7 +313,7 @@ func TestNotifyWithSuccessIsNotCalled(t *testing.T) {
|
|||
t.Fatal("Notify should not have been called")
|
||||
}
|
||||
|
||||
success := func() {
|
||||
success := func(retries int) {
|
||||
t.Fatal("Success should not have been called")
|
||||
}
|
||||
|
||||
|
@ -339,7 +339,7 @@ func TestNotifyWithSuccessIsCalled(t *testing.T) {
|
|||
}
|
||||
|
||||
successCalled := 0
|
||||
success := func() {
|
||||
success := func(retries int) {
|
||||
successCalled++
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue