From 4f6dc25c717df9e8e895c9a7db3dc66a82f9d21f Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Thu, 13 Jul 2023 11:40:41 -0700 Subject: [PATCH] app/vmalert: silence golagci-lint at TestAlertingRule_Template Add a break if gotAlert is nil This removes the following golangci-lint warning: app/vmalert/alerting_test.go:868:8: SA5011(related information): this check suggests that the pointer can be nil (staticcheck) if gotAlert == nil { ^ --- app/vmalert/alerting_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/vmalert/alerting_test.go b/app/vmalert/alerting_test.go index 61e39c371b..d05305c90d 100644 --- a/app/vmalert/alerting_test.go +++ b/app/vmalert/alerting_test.go @@ -866,8 +866,8 @@ func TestAlertingRule_Template(t *testing.T) { for hash, expAlert := range tc.expAlerts { gotAlert := tc.rule.alerts[hash] if gotAlert == nil { - t.Fatalf("alert %d is missing; labels: %v; annotations: %v", - hash, expAlert.Labels, expAlert.Annotations) + t.Fatalf("alert %d is missing; labels: %v; annotations: %v", hash, expAlert.Labels, expAlert.Annotations) + break } if !reflect.DeepEqual(expAlert.Annotations, gotAlert.Annotations) { t.Fatalf("expected to have annotations %#v; got %#v", expAlert.Annotations, gotAlert.Annotations)