From 1c63cc17472af3f5a5c034a2d1e0e320f85c41f6 Mon Sep 17 00:00:00 2001 From: Fedorov Vladimir Date: Mon, 2 Mar 2026 03:06:54 +0700 Subject: [PATCH] add mock --- go.mod | 1 + internal/modules/db/interface.go | 1 + internal/modules/db/mocks/mock.go | 223 ++++++++++++++++++++++++++++++ 3 files changed, 225 insertions(+) create mode 100644 internal/modules/db/mocks/mock.go diff --git a/go.mod b/go.mod index c3ca084..d386214 100644 --- a/go.mod +++ b/go.mod @@ -12,6 +12,7 @@ require ( require ( github.com/ghodss/yaml v1.0.0 // indirect github.com/golang/glog v1.2.5 // indirect + github.com/golang/mock v1.6.0 // indirect github.com/golang/protobuf v1.5.4 // indirect github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect github.com/phpdave11/gofpdi v1.0.14-0.20211212211723-1f10f9844311 // indirect diff --git a/internal/modules/db/interface.go b/internal/modules/db/interface.go index 7ae2578..ee73639 100644 --- a/internal/modules/db/interface.go +++ b/internal/modules/db/interface.go @@ -1,3 +1,4 @@ +//go:generate mockgen -source=interface.go -destination=mocks/mock.go -package=mocks package db import ( diff --git a/internal/modules/db/mocks/mock.go b/internal/modules/db/mocks/mock.go new file mode 100644 index 0000000..023687d --- /dev/null +++ b/internal/modules/db/mocks/mock.go @@ -0,0 +1,223 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: interface.go + +// Package mocks is a generated GoMock package. +package mocks + +import ( + context "context" + models "evening_detective/internal/models" + reflect "reflect" + + gomock "github.com/golang/mock/gomock" +) + +// MockIDBService is a mock of IDBService interface. +type MockIDBService struct { + ctrl *gomock.Controller + recorder *MockIDBServiceMockRecorder +} + +// MockIDBServiceMockRecorder is the mock recorder for MockIDBService. +type MockIDBServiceMockRecorder struct { + mock *MockIDBService +} + +// NewMockIDBService creates a new mock instance. +func NewMockIDBService(ctrl *gomock.Controller) *MockIDBService { + mock := &MockIDBService{ctrl: ctrl} + mock.recorder = &MockIDBServiceMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use. +func (m *MockIDBService) EXPECT() *MockIDBServiceMockRecorder { + return m.recorder +} + +// AddActions mocks base method. +func (m *MockIDBService) AddActions(ctx context.Context, teamId int64, actions []*models.Action) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AddActions", ctx, teamId, actions) + ret0, _ := ret[0].(error) + return ret0 +} + +// AddActions indicates an expected call of AddActions. +func (mr *MockIDBServiceMockRecorder) AddActions(ctx, teamId, actions interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddActions", reflect.TypeOf((*MockIDBService)(nil).AddActions), ctx, teamId, actions) +} + +// AddApplications mocks base method. +func (m *MockIDBService) AddApplications(ctx context.Context, teamId int64, applications []*models.Application) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AddApplications", ctx, teamId, applications) + ret0, _ := ret[0].(error) + return ret0 +} + +// AddApplications indicates an expected call of AddApplications. +func (mr *MockIDBServiceMockRecorder) AddApplications(ctx, teamId, applications interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddApplications", reflect.TypeOf((*MockIDBService)(nil).AddApplications), ctx, teamId, applications) +} + +// AddTeams mocks base method. +func (m *MockIDBService) AddTeams(ctx context.Context, teams []*models.Team) ([]*models.Team, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "AddTeams", ctx, teams) + ret0, _ := ret[0].([]*models.Team) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// AddTeams indicates an expected call of AddTeams. +func (mr *MockIDBServiceMockRecorder) AddTeams(ctx, teams interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddTeams", reflect.TypeOf((*MockIDBService)(nil).AddTeams), ctx, teams) +} + +// Close mocks base method. +func (m *MockIDBService) Close() { + m.ctrl.T.Helper() + m.ctrl.Call(m, "Close") +} + +// Close indicates an expected call of Close. +func (mr *MockIDBServiceMockRecorder) Close() *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockIDBService)(nil).Close)) +} + +// DeleteAllTeams mocks base method. +func (m *MockIDBService) DeleteAllTeams(ctx context.Context) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "DeleteAllTeams", ctx) + ret0, _ := ret[0].(error) + return ret0 +} + +// DeleteAllTeams indicates an expected call of DeleteAllTeams. +func (mr *MockIDBServiceMockRecorder) DeleteAllTeams(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "DeleteAllTeams", reflect.TypeOf((*MockIDBService)(nil).DeleteAllTeams), ctx) +} + +// GetActions mocks base method. +func (m *MockIDBService) GetActions(ctx context.Context, teamId int64) ([]*models.Action, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetActions", ctx, teamId) + ret0, _ := ret[0].([]*models.Action) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetActions indicates an expected call of GetActions. +func (mr *MockIDBServiceMockRecorder) GetActions(ctx, teamId interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetActions", reflect.TypeOf((*MockIDBService)(nil).GetActions), ctx, teamId) +} + +// GetApplications mocks base method. +func (m *MockIDBService) GetApplications(ctx context.Context, teamId int64) ([]*models.Application, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetApplications", ctx, teamId) + ret0, _ := ret[0].([]*models.Application) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetApplications indicates an expected call of GetApplications. +func (mr *MockIDBServiceMockRecorder) GetApplications(ctx, teamId interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetApplications", reflect.TypeOf((*MockIDBService)(nil).GetApplications), ctx, teamId) +} + +// GetApplicationsByState mocks base method. +func (m *MockIDBService) GetApplicationsByState(ctx context.Context, teamId int64, state string) ([]*models.Application, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetApplicationsByState", ctx, teamId, state) + ret0, _ := ret[0].([]*models.Application) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetApplicationsByState indicates an expected call of GetApplicationsByState. +func (mr *MockIDBServiceMockRecorder) GetApplicationsByState(ctx, teamId, state interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetApplicationsByState", reflect.TypeOf((*MockIDBService)(nil).GetApplicationsByState), ctx, teamId, state) +} + +// GetGame mocks base method. +func (m *MockIDBService) GetGame(ctx context.Context) (*models.Game, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetGame", ctx) + ret0, _ := ret[0].(*models.Game) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetGame indicates an expected call of GetGame. +func (mr *MockIDBServiceMockRecorder) GetGame(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetGame", reflect.TypeOf((*MockIDBService)(nil).GetGame), ctx) +} + +// GetTeam mocks base method. +func (m *MockIDBService) GetTeam(ctx context.Context, teamId, password any) (*models.Team, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTeam", ctx, teamId, password) + ret0, _ := ret[0].(*models.Team) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetTeam indicates an expected call of GetTeam. +func (mr *MockIDBServiceMockRecorder) GetTeam(ctx, teamId, password interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTeam", reflect.TypeOf((*MockIDBService)(nil).GetTeam), ctx, teamId, password) +} + +// GetTeams mocks base method. +func (m *MockIDBService) GetTeams(ctx context.Context) ([]*models.Team, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetTeams", ctx) + ret0, _ := ret[0].([]*models.Team) + ret1, _ := ret[1].(error) + return ret0, ret1 +} + +// GetTeams indicates an expected call of GetTeams. +func (mr *MockIDBServiceMockRecorder) GetTeams(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetTeams", reflect.TypeOf((*MockIDBService)(nil).GetTeams), ctx) +} + +// GiveApplications mocks base method. +func (m *MockIDBService) GiveApplications(ctx context.Context, teamId int64, applications []*models.Application) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GiveApplications", ctx, teamId, applications) + ret0, _ := ret[0].(error) + return ret0 +} + +// GiveApplications indicates an expected call of GiveApplications. +func (mr *MockIDBServiceMockRecorder) GiveApplications(ctx, teamId, applications interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GiveApplications", reflect.TypeOf((*MockIDBService)(nil).GiveApplications), ctx, teamId, applications) +} + +// UpdateGameState mocks base method. +func (m *MockIDBService) UpdateGameState(ctx context.Context, state string) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "UpdateGameState", ctx, state) + ret0, _ := ret[0].(error) + return ret0 +} + +// UpdateGameState indicates an expected call of UpdateGameState. +func (mr *MockIDBServiceMockRecorder) UpdateGameState(ctx, state interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateGameState", reflect.TypeOf((*MockIDBService)(nil).UpdateGameState), ctx, state) +}