(t *testing.T)
| 46 | } |
| 47 | |
| 48 | func TestRetriableReaderDoesNotRewrap(t *testing.T) { |
| 49 | // expected is already "retriable", as would be the case if the |
| 50 | // underlying reader was a *RetriableReader itself. |
| 51 | expected := errors.NewRetriableError(errors.New("example error")) |
| 52 | |
| 53 | r := tools.NewRetriableReader(&ErrReader{expected}) |
| 54 | |
| 55 | var buf [1]byte |
| 56 | n, err := r.Read(buf[:]) |
| 57 | |
| 58 | assert.Equal(t, 0, n) |
| 59 | // errors.NewRetriableError wraps the given error with the prefix |
| 60 | // message "LFS", so these two errors should be equal, indicating that |
| 61 | // the RetriableReader did not re-wrap the error it received. |
| 62 | assert.EqualError(t, err, expected.Error()) |
| 63 | assert.True(t, errors.IsRetriableError(err)) |
| 64 | |
| 65 | } |
| 66 | |
| 67 | // ErrReader implements io.Reader and only returns errors. |
| 68 | type ErrReader struct { |
nothing calls this directly
no test coverage detected