Example #1
0
func assertProcessEvent(event notifier.EventData, expectError bool) {
	err := notifier.ProcessEvent(event)
	if expectError {
		Expect(err).Should(HaveOccurred())
	} else {
		Expect(err).ShouldNot(HaveOccurred())

	}
}
Example #2
0
		senderSettings["type"] = "email"
		notifier.RegisterSender(senderSettings, &badSender{})
		senderSettings["type"] = "slack"
		notifier.RegisterSender(senderSettings, &timeoutSender{})
		sendersRunning = true
	})

	Context("When one invalid event arrives", func() {
		BeforeEach(func() {
			event = notifier.EventData{
				Metric:    "test1",
				State:     "OK",
				OldState:  "WARN",
				TriggerID: "",
			}
			err = notifier.ProcessEvent(event)
		})

		It("should cause an error in processing", func() {
			Expect(err).To(HaveOccurred())
		})
	})

	Context("When one valid event arrives", func() {
		Context("When event is TEST and subscription is disabled", func() {
			BeforeEach(func() {
				event = notifier.EventData{
					State:          "TEST",
					SubscriptionID: subscriptions[4].ID,
				}
				err = notifier.ProcessEvent(event)