Skip to content

Commit d8435c7

Browse files
committed
test: continue staticcheck nil guard cleanup
1 parent e0cf4d5 commit d8435c7

3 files changed

Lines changed: 26 additions & 27 deletions

File tree

internal/config/config_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,7 @@ func TestFindServer(t *testing.T) {
206206
if !tt.wantNil {
207207
if got == nil {
208208
t.Fatalf("FindServer(%q) = nil, want non-nil", tt.query)
209-
}
210-
if got.Host != tt.wantHost {
209+
} else if got.Host != tt.wantHost {
211210
t.Errorf("FindServer(%q).Host = %q, want %q", tt.query, got.Host, tt.wantHost)
212211
}
213212
}

internal/wake/wol_test.go

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -175,18 +175,19 @@ func TestSendValidMAC(t *testing.T) {
175175
}
176176
if result == nil {
177177
t.Fatal("expected non-nil result")
178-
}
179-
if result.Action != "wake" {
180-
t.Errorf("Action = %q, want %q", result.Action, "wake")
181-
}
182-
if result.MAC != tt.mac {
183-
t.Errorf("MAC = %q, want %q", result.MAC, tt.mac)
184-
}
185-
if result.Broadcast != tt.broadcast {
186-
t.Errorf("Broadcast = %q, want %q", result.Broadcast, tt.broadcast)
187-
}
188-
if result.Status != "sent" {
189-
t.Errorf("Status = %q, want %q", result.Status, "sent")
178+
} else {
179+
if result.Action != "wake" {
180+
t.Errorf("Action = %q, want %q", result.Action, "wake")
181+
}
182+
if result.MAC != tt.mac {
183+
t.Errorf("MAC = %q, want %q", result.MAC, tt.mac)
184+
}
185+
if result.Broadcast != tt.broadcast {
186+
t.Errorf("Broadcast = %q, want %q", result.Broadcast, tt.broadcast)
187+
}
188+
if result.Status != "sent" {
189+
t.Errorf("Status = %q, want %q", result.Status, "sent")
190+
}
190191
}
191192
})
192193
}

internal/watch/detector_test.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,16 @@ func TestDetectRestart_RestartCountIncrease(t *testing.T) {
4141
ev := DetectRestart(prev, curr)
4242
if ev == nil {
4343
t.Fatal("expected restart event")
44-
}
45-
if ev.RestartCount != 5 {
46-
t.Errorf("expected RestartCount=5, got %d", ev.RestartCount)
47-
}
48-
if ev.PrevStarted != "2025-01-01T00:00:00Z" {
49-
t.Errorf("unexpected PrevStarted: %s", ev.PrevStarted)
50-
}
51-
if ev.CurrStarted != "2025-01-01T01:00:00Z" {
52-
t.Errorf("unexpected CurrStarted: %s", ev.CurrStarted)
44+
} else {
45+
if ev.RestartCount != 5 {
46+
t.Errorf("expected RestartCount=5, got %d", ev.RestartCount)
47+
}
48+
if ev.PrevStarted != "2025-01-01T00:00:00Z" {
49+
t.Errorf("unexpected PrevStarted: %s", ev.PrevStarted)
50+
}
51+
if ev.CurrStarted != "2025-01-01T01:00:00Z" {
52+
t.Errorf("unexpected CurrStarted: %s", ev.CurrStarted)
53+
}
5354
}
5455
}
5556

@@ -63,8 +64,7 @@ func TestDetectRestart_StartedAtChange(t *testing.T) {
6364
ev := DetectRestart(prev, curr)
6465
if ev == nil {
6566
t.Fatal("expected restart event from StartedAt change")
66-
}
67-
if ev.Container != "redis" {
67+
} else if ev.Container != "redis" {
6868
t.Errorf("expected redis, got %s", ev.Container)
6969
}
7070
}
@@ -92,8 +92,7 @@ func TestDetectRestart_RestartCountTakesPriority(t *testing.T) {
9292
ev := DetectRestart(prev, curr)
9393
if ev == nil {
9494
t.Fatal("expected restart event from RestartCount increase")
95-
}
96-
if ev.RestartCount != 2 {
95+
} else if ev.RestartCount != 2 {
9796
t.Errorf("expected RestartCount=2, got %d", ev.RestartCount)
9897
}
9998
}

0 commit comments

Comments
 (0)