From 833276f44df6b8bb44c56c1005d97658bb18250f Mon Sep 17 00:00:00 2001 From: Ronald G Minnich Date: Wed, 22 Oct 2025 13:16:03 -0700 Subject: [PATCH] remove errors.Is in tests errors.Is(err, nil) is needed, in some places, but not here. Sometimes packages return error wrapping nil, but not in this case. But, see: https://go.dev/play/p/yjBlsllddSE Gemini confidently predicts that the code in the Playground is wrong. Oops. Thanks to brho for that test. Signed-off-by: Ronald G Minnich --- vm/initramfs_linux_test.go | 2 +- vm/vm_linux_test.go | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/vm/initramfs_linux_test.go b/vm/initramfs_linux_test.go index 1b6a036..ab5d930 100644 --- a/vm/initramfs_linux_test.go +++ b/vm/initramfs_linux_test.go @@ -19,7 +19,7 @@ func TestInitRamfs(t *testing.T) { } b, err := vm.New("linux", "amd64") - if !errors.Is(err, nil) { + if err != nil { t.Fatalf("Testing kernel=linux arch=amd64: got %v, want nil", err) } diff --git a/vm/vm_linux_test.go b/vm/vm_linux_test.go index 6d7da34..27775a6 100644 --- a/vm/vm_linux_test.go +++ b/vm/vm_linux_test.go @@ -8,7 +8,6 @@ package vm_test import ( "context" - "errors" "os" "path/filepath" "strings" @@ -23,7 +22,7 @@ import ( func TestCPUAMD64(t *testing.T) { d := t.TempDir() i, err := vm.New("linux", "amd64") - if !errors.Is(err, nil) { + if err != nil { t.Fatalf("Testing kernel=linux arch=amd64: got %v, want nil", err) } @@ -58,7 +57,7 @@ func TestCPUAMD64(t *testing.T) { {cmd: "/bbin/dd", args: []string{"if=/tmp/cpu/a", "of=/tmp/cpu/b"}, ok: true}, } { cpu, err := i.CPUCommand(tt.cmd, tt.args...) - if !errors.Is(err, nil) { + if err != nil { t.Errorf("CPUCommand: got %v, want nil", err) continue } @@ -110,7 +109,7 @@ func TestCPUAMD64(t *testing.T) { func TestCPUARM(t *testing.T) { d := t.TempDir() i, err := vm.New("linux", "arm") - if !errors.Is(err, nil) { + if err != nil { t.Fatalf("Testing kernel=linux arch=arm: got %v, want nil", err) } @@ -146,7 +145,7 @@ func TestCPUARM(t *testing.T) { {cmd: "/bbin/dd", args: []string{"if=/tmp/cpu/a", "of=/tmp/cpu/b"}, ok: true}, } { cpu, err := i.CPUCommand(tt.cmd, tt.args...) - if !errors.Is(err, nil) { + if err != nil { t.Errorf("CPUCommand: got %v, want nil", err) continue }