From ceadb92b1a120779aa040548406801f4d6d7a6db Mon Sep 17 00:00:00 2001 From: Richard Gregory Date: Mon, 4 Mar 2024 09:53:42 +0100 Subject: [PATCH] Generate mock for telegram client --- internal/client/pagerduty.go | 1 + internal/client/slack.go | 1 + internal/mocks/telegram_client.go | 65 +++++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 internal/mocks/telegram_client.go diff --git a/internal/client/pagerduty.go b/internal/client/pagerduty.go index 3770bab2..704f0366 100644 --- a/internal/client/pagerduty.go +++ b/internal/client/pagerduty.go @@ -48,6 +48,7 @@ type pagerdutyClient struct { } // NewPagerDutyClient ... Initializer for PagerDuty client +// Todo: implement error handling for client func NewPagerDutyClient(cfg *PagerDutyConfig, name string) PagerDutyClient { if cfg.IntegrationKey == "" { logging.NoContext().Warn("No PagerDuty integration key provided") diff --git a/internal/client/slack.go b/internal/client/slack.go index 9dbe2ce2..3b236be7 100644 --- a/internal/client/slack.go +++ b/internal/client/slack.go @@ -41,6 +41,7 @@ type slackClient struct { } // NewSlackClient ... Initializer +// Todo: implement error handling for client func NewSlackClient(cfg *SlackConfig, name string) SlackClient { if cfg.URL == "" { logging.NoContext().Warn("No Slack webhook URL provided") diff --git a/internal/mocks/telegram_client.go b/internal/mocks/telegram_client.go new file mode 100644 index 00000000..007bdfaa --- /dev/null +++ b/internal/mocks/telegram_client.go @@ -0,0 +1,65 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: github.com/base-org/pessimism/internal/client (interfaces: TelegramClient) + +// Package mocks is a generated GoMock package. +package mocks + +import ( + context "context" + reflect "reflect" + + client "github.com/base-org/pessimism/internal/client" + gomock "github.com/golang/mock/gomock" +) + +// MockTelegramClient is a mock of TelegramClient interface. +type MockTelegramClient struct { + ctrl *gomock.Controller + recorder *MockTelegramClientMockRecorder +} + +// MockTelegramClientMockRecorder is the mock recorder for MockTelegramClient. +type MockTelegramClientMockRecorder struct { + mock *MockTelegramClient +} + +// NewMockTelegramClient creates a new mock instance. +func NewMockTelegramClient(ctrl *gomock.Controller) *MockTelegramClient { + mock := &MockTelegramClient{ctrl: ctrl} + mock.recorder = &MockTelegramClientMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockTelegramClient) EXPECT() *MockTelegramClientMockRecorder { + return m.recorder +} + +// GetName mocks base method. +func (m *MockTelegramClient) GetName() string { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetName") + ret0, _ := ret[0].(string) + return ret0 +} + +// GetName indicates an expected call of GetName. +func (mr *MockTelegramClientMockRecorder) GetName() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetName", reflect.TypeOf((*MockTelegramClient)(nil).GetName)) +} + +// PostEvent mocks base method. +func (m *MockTelegramClient) PostEvent(arg0 context.Context, arg1 *client.AlertEventTrigger) (*client.AlertAPIResponse, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "PostEvent", arg0, arg1) + ret0, _ := ret[0].(*client.AlertAPIResponse) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// PostEvent indicates an expected call of PostEvent. +func (mr *MockTelegramClientMockRecorder) PostEvent(arg0, arg1 interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "PostEvent", reflect.TypeOf((*MockTelegramClient)(nil).PostEvent), arg0, arg1) +}