diff --git a/internal/modules/storage/mocks/interface.go b/internal/modules/storage/mocks/interface.go index 2400c28..c4f56db 100644 --- a/internal/modules/storage/mocks/interface.go +++ b/internal/modules/storage/mocks/interface.go @@ -35,6 +35,18 @@ func (m *MockIStorage) EXPECT() *MockIStorageMockRecorder { return m.recorder } +// Close mocks base method. +func (m *MockIStorage) Close() { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Close") +} + +// Close indicates an expected call of Close. +func (mr *MockIStorageMockRecorder) Close() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockIStorage)(nil).Close)) +} + // GetAllUsersByChatID mocks base method. func (m *MockIStorage) GetAllUsersByChatID(ctx context.Context, chatID string) ([]storage.User, error) { m.ctrl.T.Helper() diff --git a/internal/services/bot/bot_all/bot.go b/internal/services/bot/bot_all/bot.go index 1739902..2160730 100644 --- a/internal/services/bot/bot_all/bot.go +++ b/internal/services/bot/bot_all/bot.go @@ -26,7 +26,7 @@ func NewBotAll( } } -func (bot *botAll) Process(ctx context.Context, msg messenger.Message) error { +func (bot *botAll) Process(ctx context.Context, msg *messenger.Message) error { if err := bot.storage.UpsertUser(ctx, storage.User{ChatID: msg.ChatID, UserID: msg.UserID}); err != nil { return err } diff --git a/internal/services/bot/bot_all/bot_test.go b/internal/services/bot/bot_all/bot_test.go index f60298a..8876e1b 100644 --- a/internal/services/bot/bot_all/bot_test.go +++ b/internal/services/bot/bot_all/bot_test.go @@ -18,7 +18,7 @@ func Test_botAll_Process(t *testing.T) { name string messenger func(ctrl *gomock.Controller) messenger.IMessenger storage func(ctrl *gomock.Controller) storage.IStorage - msg messenger.Message + msg *messenger.Message wantErr bool }{ { @@ -34,7 +34,7 @@ func Test_botAll_Process(t *testing.T) { m.EXPECT().GetAllUsersByChatID(gomock.Any(), gomock.Any()).Times(0) return m }, - msg: messenger.Message{ + msg: &messenger.Message{ ChatID: "123", UserID: "username", Text: "hello", @@ -57,7 +57,7 @@ func Test_botAll_Process(t *testing.T) { Times(1) return m }, - msg: messenger.Message{ + msg: &messenger.Message{ ChatID: "123", UserID: "username", Text: "hello @all", @@ -91,7 +91,7 @@ func Test_botAll_Process(t *testing.T) { Times(1) return m }, - msg: messenger.Message{ + msg: &messenger.Message{ ChatID: "123", UserID: "username", Text: "hello @all", @@ -126,7 +126,7 @@ func Test_botAll_Process(t *testing.T) { Times(1) return m }, - msg: messenger.Message{ + msg: &messenger.Message{ ChatID: "123", UserID: "username", Text: "hello @all", diff --git a/internal/services/bot/interface.go b/internal/services/bot/interface.go index 56443cb..ccd6609 100644 --- a/internal/services/bot/interface.go +++ b/internal/services/bot/interface.go @@ -7,5 +7,5 @@ import ( ) type IBot interface { - Process(ctx context.Context, msg messenger.Message) error + Process(ctx context.Context, msg *messenger.Message) error } diff --git a/internal/services/listener/listener.go b/internal/services/listener/listener.go index 45f9433..56d2b2c 100644 --- a/internal/services/listener/listener.go +++ b/internal/services/listener/listener.go @@ -33,7 +33,7 @@ func (s *listenerService) Run(ctx context.Context) error { } return err } - for b := range s.bots { + for _, b := range s.bots { if err := b.Process(ctx, msg); err != nil { log.Println(err) }