Implement test for no space error handling

Add test for backend load with no space error not retried.
This commit is contained in:
Michael Mendy 2026-05-25 08:31:08 -07:00 committed by GitHub
parent 7b77c4dc0b
commit ec9ecb2875
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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")