mirror of
https://github.com/restic/restic.git
synced 2026-05-28 04:35:41 -04:00
Implement test for no space error handling
Add test for backend load with no space error not retried.
This commit is contained in:
parent
7b77c4dc0b
commit
ec9ecb2875
1 changed files with 25 additions and 0 deletions
|
|
@ -285,6 +285,31 @@ func TestBackendLoadRetry(t *testing.T) {
|
|||
test.Equals(t, 2, attempt)
|
||||
}
|
||||
|
||||
func TestBackendLoadNoSpaceNotRetried(t *testing.T) {
|
||||
noSpaceErr := &os.PathError{
|
||||
Op: "write",
|
||||
Path: "/tmp/restic-check-cache/data/tmp-123",
|
||||
Err: errNoSpace,
|
||||
}
|
||||
|
||||
attempt := 0
|
||||
be := mock.NewBackend()
|
||||
be.OpenReaderFn = func(ctx context.Context, h backend.Handle, length int, offset int64) (io.ReadCloser, error) {
|
||||
attempt++
|
||||
return nil, noSpaceErr
|
||||
}
|
||||
|
||||
TestFastRetries(t)
|
||||
retryBackend := New(be, time.Second, nil, nil)
|
||||
|
||||
err := retryBackend.Load(context.TODO(), backend.Handle{}, 0, 0, func(rd io.Reader) error {
|
||||
return nil
|
||||
})
|
||||
|
||||
test.Equals(t, noSpaceErr, err)
|
||||
test.Equals(t, 1, attempt)
|
||||
}
|
||||
|
||||
func testBackendLoadNotExists(t *testing.T, hasFlakyErrors bool) {
|
||||
// load should not retry if the error matches IsNotExist
|
||||
notFound := errors.New("not found")
|
||||
|
|
|
|||
Loading…
Reference in a new issue