From b0ec737973d2aafa909ec5e608c5eb52b2d2c50e Mon Sep 17 00:00:00 2001 From: Andrey Kolkov Date: Fri, 5 Mar 2021 16:35:43 +0400 Subject: [PATCH] fix tests --- notifier/notifier.go | 4 ++++ notifier/notifier_test.go | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/notifier/notifier.go b/notifier/notifier.go index 241381216..0f0b1c666 100644 --- a/notifier/notifier.go +++ b/notifier/notifier.go @@ -216,6 +216,10 @@ func disableBrokenContactSubscriptions(brokenContact *moira.ContactData, databas if err != nil { return 0, err } + if len(subsIDs) == 0 { + return 0, nil + } + subs, e := database.GetSubscriptions(subsIDs) if e != nil { return 0, e diff --git a/notifier/notifier_test.go b/notifier/notifier_test.go index d2009a655..6b1f0f71c 100644 --- a/notifier/notifier_test.go +++ b/notifier/notifier_test.go @@ -131,10 +131,12 @@ func TestNoResendForSendToBrokenContact(t *testing.T) { Events: eventsData, Contact: moira.ContactData{ Type: "test", + User: "someuser", }, } sender.EXPECT().SendEvents(eventsData, pkg.Contact, pkg.Trigger, plots, pkg.Throttled). Return(moira.NewSenderBrokenContactError(fmt.Errorf("some sender reason"))) + dataBase.EXPECT().GetUserSubscriptionIDs(pkg.Contact.User).Return([]string{}, nil) var wg sync.WaitGroup notif.Send(&pkg, &wg) @@ -236,7 +238,8 @@ func afterTest() { var subID = "SubscriptionID-000000000000001" var event = moira.NotificationEvent{ - Metric: "generate.event.1", + Metric: "generate.event.1", + State: moira.StateOK, OldState: moira.StateWARN, TriggerID: "triggerID-0000000000001",