mirror of
https://github.com/golang/go
synced 2024-11-24 04:50:07 -07:00
os: fix wrong error msg from TestReadClosed
If test would fail, the error message will have wrong error and its
type, because e is used after the failed type assertion.
To fix, use the original err.
While at it,
- combine the checks for error type and value into one statement;
- use the standard "got ..., want ..." format.
Fixes: 212d2f82e0
("os: add ErrClosed, return for use of closed File")
Change-Id: I862a96607b461ab89cce6bed2443b28aa2c16468
Reviewed-on: https://go-review.googlesource.com/c/go/+/428915
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
This commit is contained in:
parent
5a96386922
commit
88149ed43e
@ -314,12 +314,8 @@ func TestReadClosed(t *testing.T) {
|
||||
_, err = file.Read(b)
|
||||
|
||||
e, ok := err.(*PathError)
|
||||
if !ok {
|
||||
t.Fatalf("Read: %T(%v), want PathError", e, e)
|
||||
}
|
||||
|
||||
if e.Err != ErrClosed {
|
||||
t.Errorf("Read: %v, want PathError(ErrClosed)", e)
|
||||
if !ok || e.Err != ErrClosed {
|
||||
t.Fatalf("Read: got %T(%v), want %T(%v)", err, err, e, ErrClosed)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user