(t *testing.T)
| 66 | } |
| 67 | |
| 68 | func TestIsTransientError(t *testing.T) { |
| 69 | tests := []struct { |
| 70 | name string |
| 71 | err error |
| 72 | want bool |
| 73 | }{ |
| 74 | {"nil", nil, false}, |
| 75 | {"permanent error", errors.New("path/not_found"), false}, |
| 76 | {"auth error", errors.New("invalid_access_token"), false}, |
| 77 | { |
| 78 | "server error 5xx", |
| 79 | auth.ServerError{APIError: dropbox.APIError{ErrorSummary: "internal"}}, |
| 80 | true, |
| 81 | }, |
| 82 | { |
| 83 | "rate limit error", |
| 84 | auth.RateLimitAPIError{RateLimitError: auth.NewRateLimitError(nil)}, |
| 85 | true, |
| 86 | }, |
| 87 | { |
| 88 | "sdk internal 500", |
| 89 | dropbox.SDKInternalError{StatusCode: 500, Content: "server error"}, |
| 90 | true, |
| 91 | }, |
| 92 | { |
| 93 | "sdk internal 503", |
| 94 | dropbox.SDKInternalError{StatusCode: 503, Content: "unavailable"}, |
| 95 | true, |
| 96 | }, |
| 97 | { |
| 98 | "sdk internal 400 (not transient)", |
| 99 | dropbox.SDKInternalError{StatusCode: 400, Content: "bad request"}, |
| 100 | false, |
| 101 | }, |
| 102 | { |
| 103 | "net error", |
| 104 | &net.OpError{Op: "read", Net: "tcp", Err: errors.New("reset")}, |
| 105 | true, |
| 106 | }, |
| 107 | { |
| 108 | "single-shot upload too many write operations", |
| 109 | uploadWriteThrottleError(), |
| 110 | true, |
| 111 | }, |
| 112 | { |
| 113 | "upload session finish too many write operations", |
| 114 | finishTooManyWriteOperationsError(), |
| 115 | true, |
| 116 | }, |
| 117 | { |
| 118 | "single-shot upload write conflict", |
| 119 | uploadWriteConflictError(), |
| 120 | false, |
| 121 | }, |
| 122 | { |
| 123 | "unexpected EOF", |
| 124 | io.ErrUnexpectedEOF, |
| 125 | true, |
nothing calls this directly
no test coverage detected