Files
houston-be/service/reminder/sla_breach_reminder_test.go
Vijay Joshi 0d613a4bfb INFRA-2887 : SLA breach heads up cron refactor/reimplementation (#411)
* INFRA-2887 : SLA breach heads up cron refactor/reimplementation

* INFRA-2887 : Code review comments
2024-04-01 19:18:38 +05:30

44 lines
2.0 KiB
Go

package reminder
import (
"errors"
"houston/common/util"
"houston/model/incident"
)
func (suite *ReminderServiceSuite) Test_PostSlaBreachMessages_GetSeverityEscalationMapError() {
suite.severityService.GetSeverityEscalationMapMock.Return(nil, errors.New("error"))
err := suite.reminderService.PostSlaBreachMessages()
suite.Error(err, "service should return error")
}
func (suite *ReminderServiceSuite) Test_PostSlaBreachMessages_IncidentFetchingError() {
suite.severityService.GetSeverityEscalationMapMock.Return(util.GetMockSeverityEscalationMap(), nil)
suite.incidentService.FetchIncidentsApproachingSlaBreachMock.Return(nil, errors.New("error"))
err := suite.reminderService.PostSlaBreachMessages()
suite.Error(err, "service should return error")
}
func (suite *ReminderServiceSuite) Test_PostSlaBreachMessages_NoIncidents() {
suite.severityService.GetSeverityEscalationMapMock.Return(util.GetMockSeverityEscalationMap(), nil)
suite.incidentService.FetchIncidentsApproachingSlaBreachMock.Return([]incident.IncidentDTO{}, nil)
err := suite.reminderService.PostSlaBreachMessages()
suite.NoError(err, "service should not return error")
}
func (suite *ReminderServiceSuite) Test_PostSlaBreachMessages_SlackFailure() {
suite.severityService.GetSeverityEscalationMapMock.Return(util.GetMockSeverityEscalationMap(), nil)
suite.incidentService.FetchIncidentsApproachingSlaBreachMock.Return(getMockIncidentsData(), nil)
suite.slackService.PostMessageOptionMock.Return("", errors.New("error"))
err := suite.reminderService.PostSlaBreachMessages()
suite.Error(err, "service should return error")
}
func (suite *ReminderServiceSuite) Test_PostSlaBreachMessages_Success() {
suite.severityService.GetSeverityEscalationMapMock.Return(util.GetMockSeverityEscalationMap(), nil)
suite.incidentService.FetchIncidentsApproachingSlaBreachMock.Return(getMockIncidentsData(), nil)
suite.slackService.PostMessageOptionMock.Return("", nil)
err := suite.reminderService.PostSlaBreachMessages()
suite.NoError(err, "service should not return error")
}