Skip to content

Commit 833276f

Browse files
committed
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 <rminnich@gmail.com>
1 parent ae0b912 commit 833276f

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

vm/initramfs_linux_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func TestInitRamfs(t *testing.T) {
1919
}
2020

2121
b, err := vm.New("linux", "amd64")
22-
if !errors.Is(err, nil) {
22+
if err != nil {
2323
t.Fatalf("Testing kernel=linux arch=amd64: got %v, want nil", err)
2424
}
2525

vm/vm_linux_test.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ package vm_test
88

99
import (
1010
"context"
11-
"errors"
1211
"os"
1312
"path/filepath"
1413
"strings"
@@ -23,7 +22,7 @@ import (
2322
func TestCPUAMD64(t *testing.T) {
2423
d := t.TempDir()
2524
i, err := vm.New("linux", "amd64")
26-
if !errors.Is(err, nil) {
25+
if err != nil {
2726
t.Fatalf("Testing kernel=linux arch=amd64: got %v, want nil", err)
2827
}
2928

@@ -58,7 +57,7 @@ func TestCPUAMD64(t *testing.T) {
5857
{cmd: "/bbin/dd", args: []string{"if=/tmp/cpu/a", "of=/tmp/cpu/b"}, ok: true},
5958
} {
6059
cpu, err := i.CPUCommand(tt.cmd, tt.args...)
61-
if !errors.Is(err, nil) {
60+
if err != nil {
6261
t.Errorf("CPUCommand: got %v, want nil", err)
6362
continue
6463
}
@@ -110,7 +109,7 @@ func TestCPUAMD64(t *testing.T) {
110109
func TestCPUARM(t *testing.T) {
111110
d := t.TempDir()
112111
i, err := vm.New("linux", "arm")
113-
if !errors.Is(err, nil) {
112+
if err != nil {
114113
t.Fatalf("Testing kernel=linux arch=arm: got %v, want nil", err)
115114
}
116115

@@ -146,7 +145,7 @@ func TestCPUARM(t *testing.T) {
146145
{cmd: "/bbin/dd", args: []string{"if=/tmp/cpu/a", "of=/tmp/cpu/b"}, ok: true},
147146
} {
148147
cpu, err := i.CPUCommand(tt.cmd, tt.args...)
149-
if !errors.Is(err, nil) {
148+
if err != nil {
150149
t.Errorf("CPUCommand: got %v, want nil", err)
151150
continue
152151
}

0 commit comments

Comments
 (0)