On Sat, Oct 23, 2021 at 11:47:42PM +0300, Nir Soffer wrote:
Use type assertion[1] to convert err to the concrete LibnbdError so
we
can verify the expected Errno. The assertion will panic if err is not a
LibnbdError.
[1]
https://tour.golang.org/methods/15
Signed-off-by: Nir Soffer <nsoffer(a)redhat.com>
---
golang/src/libguestfs.org/libnbd/libnbd_610_error_test.go | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git
a/golang/src/libguestfs.org/libnbd/libnbd_610_error_test.go
b/golang/src/libguestfs.org/libnbd/libnbd_610_error_test.go
index 27540ce..0f81e76 100644
---
a/golang/src/libguestfs.org/libnbd/libnbd_610_error_test.go
+++
b/golang/src/libguestfs.org/libnbd/libnbd_610_error_test.go
@@ -18,7 +18,7 @@
package libnbd
-import "fmt"
+import "syscall"
import "testing"
func Test610Error(t *testing.T) {
@@ -34,8 +34,7 @@ func Test610Error(t *testing.T) {
err = h.Pread(buf, 0, nil)
if err == nil {
t.Fatalf("expected an error from operation")
+ } else if err.(*LibnbdError).Errno != syscall.ENOTCONN {
+ t.Fatalf("unexpected error: %s", err)
}
- fmt.Printf("error = %s\n", err)
- /* XXX We expect the errno to be ENOTCONN, but I couldn't work
- out how to test it. */
}
ACK series
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-builder quickly builds VMs from scratch
http://libguestfs.org/virt-builder.1.html