-
Notifications
You must be signed in to change notification settings - Fork 17.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
testing/iotest: add ErrReader #38781
Comments
I'd call it ErrReader, to match DataErrReader, but this seems fine to me.
|
EDIT: updated PR as well. |
Adding to proposal minutes. Seems fine to me, as I said before. |
Based on how trivial this is and the lack of any objections, this seems like a likely accept. |
No change in consensus, so accepted. |
I think the "help wanted" tag got mangled? |
@networkimprov Thanks, fixed. |
Do I need to do anything else here to get #34741 merged? |
This is a very useful addition in the stdlib. I was wondering why this has to fail immediately and return 0 bytes read? If the number of bytes read is set during the tests, ErrReader could potentially cover more cases Example: func ErrReader(n int) io.Reader {
return &errReader{n}
}
type errReader struct{
n int
}
func (r *errReader) Read(p []byte) (int, error) {
return n, ErrIO
} @caarlos0 does it make sense? |
@caarlos0 You don't need to do anything at the moment. We are currently in a release freeze for 1.15. After the 1.15 release goes out, we can review the CL. Thanks for sending it. Personally I think we should stick with the simple |
Change https://golang.org/cl/199501 mentions this issue: |
Change https://golang.org/cl/248898 mentions this issue: |
Corrects ErrReader's signature to what was accepted in the approved proposal, and also removes an exported ErrIO which wasn't part of the proposal and is unnecessary. The new signature allows users to customize their own errors. While here, started examples, with ErrReader leading the way. Updates #38781 Change-Id: Ia7f84721f11061343cfef8b1adc2b7b69bc3f43c Reviewed-on: https://go-review.googlesource.com/c/go/+/248898 Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Change https://golang.org/cl/249037 mentions this issue: |
Updates #38781 Change-Id: I16a66904167ca4c0e916619b4da1dd23795b3ab2 GitHub-Last-Rev: 4505423 GitHub-Pull-Request: #40864 Reviewed-on: https://go-review.googlesource.com/c/go/+/249037 Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Change https://golang.org/cl/285673 mentions this issue: |
For #38781 For #40700 For #41190 Change-Id: I72f1055e51edb517041d3861640734ba6ef5f342 Reviewed-on: https://go-review.googlesource.com/c/go/+/285673 Trust: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Abstract
Add a
iotest.ErrReader
io.Reader
implementation that reads 0 bytes and fails.This would be useful for quickly adding test cases for when
Read
doesn't work for some reason.Background
The
iotest
package already have a couple of otherio.Reader
implementations, but we don't have any that fails right away.On nearly all codebases I worked in, I created this same
failReader
/errReader
implementation. Judging by this and this github searches, I'm not alone.Proposal
Add it to the standard library, under the
iotest
package.I actually have the PR opened already: #34741
Rationale
Make it easier to add test cases for read failures.
The text was updated successfully, but these errors were encountered: