Read reads data from the testReader, simulating a slow read and a potential failure
(p []byte)
| 52 | |
| 53 | // Read reads data from the testReader, simulating a slow read and a potential failure |
| 54 | func (r *erraticReader) Read(p []byte) (n int, err error) { |
| 55 | cur := r.reader.BytesRead() |
| 56 | if r.failAt > 0 && r.failAt < cur+int64(len(p)) { |
| 57 | return 0, errors.New("simulated read failure") |
| 58 | } |
| 59 | return r.reader.Read(p) |
| 60 | } |
| 61 | |
| 62 | // Close forwards closing to the underlying reader |
| 63 | func (r *erraticReader) Close() error { |
no test coverage detected