From ea864f9b37131171c27a285bcf337ffa61a4f2fd 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 ++++- senders/telegram/send.go | 1 - 3 files changed, 8 insertions(+), 2 deletions(-) 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", diff --git a/senders/telegram/send.go b/senders/telegram/send.go index c3789d663..5b73c6799 100644 --- a/senders/telegram/send.go +++ b/senders/telegram/send.go @@ -3,7 +3,6 @@ package telegram import ( "bytes" "fmt" - "github.com/moira-alert/moira/notifier" "strings" "gopkg.in/tucnak/telebot.v2"