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 {
				   ^
This commit is contained in:
Aliaksandr Valialkin 2023-07-13 11:40:41 -07:00
parent a79e53d82a
commit 4f6dc25c71
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1

View file

@ -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)