NTP-4943 | updated unit tests of incident service (#462)

This commit is contained in:
Shashank Shekhar
2024-11-12 16:24:06 +05:30
committed by GitHub
parent 85a1c89ca6
commit bf9052f75c
6 changed files with 24 additions and 19 deletions

View File

@@ -5,7 +5,6 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/spf13/viper"
"go.uber.org/zap"
"houston/contracts"
"houston/logger"
@@ -21,15 +20,6 @@ type EEMonitoringServiceClientImpl struct {
WebhookAPIPath string
}
func NewEEMonitoringServiceActionsImpl(client rest.HttpRestClient) *EEMonitoringServiceClientImpl {
return &EEMonitoringServiceClientImpl{
Client: client,
BaseURL: viper.GetString("EE_MONITORING_SERVICE_BASEURL"),
DefaultTimeout: viper.GetDuration("DEFAULT_EE_MONITORING_SERVICE_TIMEOUT"),
WebhookAPIPath: viper.GetString("EE_MONITORING_SERVICE_WEBHOOK_API_PATH"),
}
}
func (client *EEMonitoringServiceClientImpl) TriggerSeverityUpdateWebhook(
incidentId uint,
triggerredBy string,

View File

@@ -1,9 +1,22 @@
package monitoringService
import "houston/contracts"
import (
"github.com/spf13/viper"
"houston/contracts"
"houston/pkg/rest"
)
type EEMonitoringServiceClient interface {
TriggerSeverityUpdateWebhook(
incidentId uint, triggerredBy string, requestId string, oldSeverity, newSeverity contracts.SeverityInfo,
) error
}
func NewEEMonitoringServiceClient(client rest.HttpRestClient) EEMonitoringServiceClient {
return &EEMonitoringServiceClientImpl{
Client: client,
BaseURL: viper.GetString("EE_MONITORING_SERVICE_BASEURL"),
DefaultTimeout: viper.GetDuration("DEFAULT_EE_MONITORING_SERVICE_TIMEOUT"),
WebhookAPIPath: viper.GetString("EE_MONITORING_SERVICE_WEBHOOK_API_PATH"),
}
}

View File

@@ -52,7 +52,7 @@ func (suite *EEMonitoringServiceSuite) Test_TriggerWebhook_ErrorResponseCase() {
responseChannel := make(chan service.MonitoringServiceClientResponse)
defer close(responseChannel)
err := NewEEMonitoringServiceActionsImpl(restClient).TriggerSeverityUpdateWebhook(
err := NewEEMonitoringServiceClient(restClient).TriggerSeverityUpdateWebhook(
1, "test", requestId, getOldSeverity(), getNewSeverity(),
)
suite.Error(err)
@@ -84,7 +84,7 @@ func (suite *EEMonitoringServiceSuite) Test_TriggerWebhook_SuccessCase() {
responseChannel := make(chan service.MonitoringServiceClientResponse)
defer close(responseChannel)
err := NewEEMonitoringServiceActionsImpl(restClient).TriggerSeverityUpdateWebhook(
err := NewEEMonitoringServiceClient(restClient).TriggerSeverityUpdateWebhook(
1, "test", requestId, getOldSeverity(), getNewSeverity(),
)