]> Cypherpunks repositories - gostls13.git/commitdiff
os: fix wrong error msg from TestDoubleCloseError
authorKir Kolyshkin <kolyshkin@gmail.com>
Wed, 7 Sep 2022 01:09:11 +0000 (18:09 -0700)
committerGopher Robot <gobot@golang.org>
Thu, 8 Sep 2022 21:19:00 +0000 (21:19 +0000)
When the type assertion fails, the test mistakenly prints the expected
(rather than the actual) type.

When the error string doesn't match, the text mistakenly prints the
original (rather than the converted) error (although there might not be
any difference in the output, the code looks wrong).

Fix both issues.

Change-Id: Ia7dd0632fc677f458fec25d899c46268a12f76e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/428916
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
src/os/os_test.go

index 45d3aa6b5e9f9059fd8bd6df1af4ed7969475e3f..4c64afaef06081814b17eef96e28b7b39fa9404e 100644 (file)
@@ -2539,9 +2539,9 @@ func testDoubleCloseError(t *testing.T, path string) {
        if err := file.Close(); err == nil {
                t.Error("second Close did not fail")
        } else if pe, ok := err.(*PathError); !ok {
-               t.Errorf("second Close returned unexpected error type %T; expected fs.PathError", pe)
+               t.Errorf("second Close: got %T, want %T", err, pe)
        } else if pe.Err != ErrClosed {
-               t.Errorf("second Close returned %q, wanted %q", err, ErrClosed)
+               t.Errorf("second Close: got %q, want %q", pe.Err, ErrClosed)
        } else {
                t.Logf("second close returned expected error %q", err)
        }