1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
package errors_test
import (
"net/url"
"testing"
"github.com/git-lfs/git-lfs/v3/errors"
"github.com/stretchr/testify/assert"
)
type TemporaryError struct {
}
func (e TemporaryError) Error() string {
return ""
}
func (e TemporaryError) Temporary() bool {
return true
}
type TimeoutError struct {
}
func (e TimeoutError) Error() string {
return ""
}
func (e TimeoutError) Timeout() bool {
return true
}
func TestCanRetryOnTemporaryError(t *testing.T) {
err := &url.Error{Err: TemporaryError{}}
assert.True(t, errors.IsRetriableError(err))
}
func TestCanRetryOnTimeoutError(t *testing.T) {
err := &url.Error{Err: TimeoutError{}}
assert.True(t, errors.IsRetriableError(err))
}
func TestCannotRetryOnGenericUrlError(t *testing.T) {
err := &url.Error{Err: errors.New("")}
assert.False(t, errors.IsRetriableError(err))
}
|