diff --git a/.gitignore b/.gitignore index 956489d5d..72bd4bf3e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,26 +1,48 @@ # Binaries bin + .vscode +.zed +.idea +.trae +.cursor + .DS_Store .envrc -.idea/ - +.codesouler /gitea /pgdata minio_data local_only /jetstream .env -*.sh +memory +docker-compose-leida.yml +run_account_local.sh +run_callback_local.sh +run_deploy_runner_local.sh +run_rproxy_local.sh +run_server_local.sh +run_user_local.sh +run_aigateway_local.sh +run_server_my_local.sh +run_payment_local.sh cmd/csghub-server/__debug_* +run_dataviewer_local.sh +run_notification_local.sh +run_temporal_worker.sh +local.toml +loki-config.yml .data +/data */*/_api_test/ redis/dump.rdb -run_server_local.sh **/loki-data/ **/tempo-data/ docs/swagger.json docs/swagger.yaml docs/docs.go +pgdata15/ + diff --git a/.mockery.yaml b/.mockery.yaml index 45e21a71c..6c2540d0d 100644 --- a/.mockery.yaml +++ b/.mockery.yaml @@ -10,49 +10,7 @@ packages: Reader: opencsg.com/csghub-server/component: config: - interfaces: - ApiRateLimit: - RepoComponent: - TagComponent: - AccountingComponent: - SpaceComponent: - SpaceResourceComponent: - RuntimeArchitectureComponent: - SensitiveComponent: - CodeComponent: - PromptComponent: - ModelComponent: - UserComponent: - GitHTTPComponent: - DiscussionComponent: - DatasetComponent: - CollectionComponent: - BroadcastComponent: - InternalComponent: - MirrorSourceComponent: - MirrorComponent: - ImportComponent: - EvaluationComponent: - FinetuneComponent: - RecomComponent: - MultiSyncComponent: - ModelTreeComponent: - SpaceTemplateComponent: - RuleComponent: - MCPServerComponent: - MCPScannerComponent: - MCPScannerPlugin: - StatComponent: - LLMServiceComponent: - MonitorComponent: - ClusterComponent: - MirrorNamespaceMappingComponent: - NotebookComponent: - LicenseComponent: - CaptchaComponent: - AgentComponent: - AgentInstanceAdapter: - XnetComponent: + all: true opencsg.com/csghub-server/component/reporter: config: interfaces: diff --git a/_mocks/opencsg.com/csghub-server/builder/store/database/mock_AgentConfigStore.go b/_mocks/opencsg.com/csghub-server/builder/store/database/mock_AgentConfigStore.go new file mode 100644 index 000000000..358ef09a9 --- /dev/null +++ b/_mocks/opencsg.com/csghub-server/builder/store/database/mock_AgentConfigStore.go @@ -0,0 +1,414 @@ +// Code generated by mockery v2.53.5. DO NOT EDIT. + +package database + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + database "opencsg.com/csghub-server/builder/store/database" +) + +// MockAgentConfigStore is an autogenerated mock type for the AgentConfigStore type +type MockAgentConfigStore struct { + mock.Mock +} + +type MockAgentConfigStore_Expecter struct { + mock *mock.Mock +} + +func (_m *MockAgentConfigStore) EXPECT() *MockAgentConfigStore_Expecter { + return &MockAgentConfigStore_Expecter{mock: &_m.Mock} +} + +// Create provides a mock function with given fields: ctx, config +func (_m *MockAgentConfigStore) Create(ctx context.Context, config *database.AgentConfig) error { + ret := _m.Called(ctx, config) + + if len(ret) == 0 { + panic("no return value specified for Create") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, *database.AgentConfig) error); ok { + r0 = rf(ctx, config) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockAgentConfigStore_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockAgentConfigStore_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - config *database.AgentConfig +func (_e *MockAgentConfigStore_Expecter) Create(ctx interface{}, config interface{}) *MockAgentConfigStore_Create_Call { + return &MockAgentConfigStore_Create_Call{Call: _e.mock.On("Create", ctx, config)} +} + +func (_c *MockAgentConfigStore_Create_Call) Run(run func(ctx context.Context, config *database.AgentConfig)) *MockAgentConfigStore_Create_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*database.AgentConfig)) + }) + return _c +} + +func (_c *MockAgentConfigStore_Create_Call) Return(_a0 error) *MockAgentConfigStore_Create_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAgentConfigStore_Create_Call) RunAndReturn(run func(context.Context, *database.AgentConfig) error) *MockAgentConfigStore_Create_Call { + _c.Call.Return(run) + return _c +} + +// Delete provides a mock function with given fields: ctx, id +func (_m *MockAgentConfigStore) Delete(ctx context.Context, id int64) error { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for Delete") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, int64) error); ok { + r0 = rf(ctx, id) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockAgentConfigStore_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' +type MockAgentConfigStore_Delete_Call struct { + *mock.Call +} + +// Delete is a helper method to define mock.On call +// - ctx context.Context +// - id int64 +func (_e *MockAgentConfigStore_Expecter) Delete(ctx interface{}, id interface{}) *MockAgentConfigStore_Delete_Call { + return &MockAgentConfigStore_Delete_Call{Call: _e.mock.On("Delete", ctx, id)} +} + +func (_c *MockAgentConfigStore_Delete_Call) Run(run func(ctx context.Context, id int64)) *MockAgentConfigStore_Delete_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(int64)) + }) + return _c +} + +func (_c *MockAgentConfigStore_Delete_Call) Return(_a0 error) *MockAgentConfigStore_Delete_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAgentConfigStore_Delete_Call) RunAndReturn(run func(context.Context, int64) error) *MockAgentConfigStore_Delete_Call { + _c.Call.Return(run) + return _c +} + +// GetByID provides a mock function with given fields: ctx, id +func (_m *MockAgentConfigStore) GetByID(ctx context.Context, id int64) (*database.AgentConfig, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for GetByID") + } + + var r0 *database.AgentConfig + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, int64) (*database.AgentConfig, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, int64) *database.AgentConfig); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*database.AgentConfig) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, int64) error); ok { + r1 = rf(ctx, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAgentConfigStore_GetByID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByID' +type MockAgentConfigStore_GetByID_Call struct { + *mock.Call +} + +// GetByID is a helper method to define mock.On call +// - ctx context.Context +// - id int64 +func (_e *MockAgentConfigStore_Expecter) GetByID(ctx interface{}, id interface{}) *MockAgentConfigStore_GetByID_Call { + return &MockAgentConfigStore_GetByID_Call{Call: _e.mock.On("GetByID", ctx, id)} +} + +func (_c *MockAgentConfigStore_GetByID_Call) Run(run func(ctx context.Context, id int64)) *MockAgentConfigStore_GetByID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(int64)) + }) + return _c +} + +func (_c *MockAgentConfigStore_GetByID_Call) Return(_a0 *database.AgentConfig, _a1 error) *MockAgentConfigStore_GetByID_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAgentConfigStore_GetByID_Call) RunAndReturn(run func(context.Context, int64) (*database.AgentConfig, error)) *MockAgentConfigStore_GetByID_Call { + _c.Call.Return(run) + return _c +} + +// GetByName provides a mock function with given fields: ctx, name +func (_m *MockAgentConfigStore) GetByName(ctx context.Context, name string) (*database.AgentConfig, error) { + ret := _m.Called(ctx, name) + + if len(ret) == 0 { + panic("no return value specified for GetByName") + } + + var r0 *database.AgentConfig + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*database.AgentConfig, error)); ok { + return rf(ctx, name) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *database.AgentConfig); ok { + r0 = rf(ctx, name) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*database.AgentConfig) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, name) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAgentConfigStore_GetByName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByName' +type MockAgentConfigStore_GetByName_Call struct { + *mock.Call +} + +// GetByName is a helper method to define mock.On call +// - ctx context.Context +// - name string +func (_e *MockAgentConfigStore_Expecter) GetByName(ctx interface{}, name interface{}) *MockAgentConfigStore_GetByName_Call { + return &MockAgentConfigStore_GetByName_Call{Call: _e.mock.On("GetByName", ctx, name)} +} + +func (_c *MockAgentConfigStore_GetByName_Call) Run(run func(ctx context.Context, name string)) *MockAgentConfigStore_GetByName_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockAgentConfigStore_GetByName_Call) Return(_a0 *database.AgentConfig, _a1 error) *MockAgentConfigStore_GetByName_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAgentConfigStore_GetByName_Call) RunAndReturn(run func(context.Context, string) (*database.AgentConfig, error)) *MockAgentConfigStore_GetByName_Call { + _c.Call.Return(run) + return _c +} + +// GetConfigValue provides a mock function with given fields: ctx, name, key +func (_m *MockAgentConfigStore) GetConfigValue(ctx context.Context, name string, key string) (any, error) { + ret := _m.Called(ctx, name, key) + + if len(ret) == 0 { + panic("no return value specified for GetConfigValue") + } + + var r0 any + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string) (any, error)); ok { + return rf(ctx, name, key) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string) any); ok { + r0 = rf(ctx, name, key) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(any) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { + r1 = rf(ctx, name, key) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAgentConfigStore_GetConfigValue_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetConfigValue' +type MockAgentConfigStore_GetConfigValue_Call struct { + *mock.Call +} + +// GetConfigValue is a helper method to define mock.On call +// - ctx context.Context +// - name string +// - key string +func (_e *MockAgentConfigStore_Expecter) GetConfigValue(ctx interface{}, name interface{}, key interface{}) *MockAgentConfigStore_GetConfigValue_Call { + return &MockAgentConfigStore_GetConfigValue_Call{Call: _e.mock.On("GetConfigValue", ctx, name, key)} +} + +func (_c *MockAgentConfigStore_GetConfigValue_Call) Run(run func(ctx context.Context, name string, key string)) *MockAgentConfigStore_GetConfigValue_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string)) + }) + return _c +} + +func (_c *MockAgentConfigStore_GetConfigValue_Call) Return(_a0 any, _a1 error) *MockAgentConfigStore_GetConfigValue_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAgentConfigStore_GetConfigValue_Call) RunAndReturn(run func(context.Context, string, string) (any, error)) *MockAgentConfigStore_GetConfigValue_Call { + _c.Call.Return(run) + return _c +} + +// List provides a mock function with given fields: ctx +func (_m *MockAgentConfigStore) List(ctx context.Context) ([]*database.AgentConfig, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for List") + } + + var r0 []*database.AgentConfig + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) ([]*database.AgentConfig, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) []*database.AgentConfig); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*database.AgentConfig) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAgentConfigStore_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' +type MockAgentConfigStore_List_Call struct { + *mock.Call +} + +// List is a helper method to define mock.On call +// - ctx context.Context +func (_e *MockAgentConfigStore_Expecter) List(ctx interface{}) *MockAgentConfigStore_List_Call { + return &MockAgentConfigStore_List_Call{Call: _e.mock.On("List", ctx)} +} + +func (_c *MockAgentConfigStore_List_Call) Run(run func(ctx context.Context)) *MockAgentConfigStore_List_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *MockAgentConfigStore_List_Call) Return(_a0 []*database.AgentConfig, _a1 error) *MockAgentConfigStore_List_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAgentConfigStore_List_Call) RunAndReturn(run func(context.Context) ([]*database.AgentConfig, error)) *MockAgentConfigStore_List_Call { + _c.Call.Return(run) + return _c +} + +// Update provides a mock function with given fields: ctx, config +func (_m *MockAgentConfigStore) Update(ctx context.Context, config *database.AgentConfig) error { + ret := _m.Called(ctx, config) + + if len(ret) == 0 { + panic("no return value specified for Update") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, *database.AgentConfig) error); ok { + r0 = rf(ctx, config) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockAgentConfigStore_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' +type MockAgentConfigStore_Update_Call struct { + *mock.Call +} + +// Update is a helper method to define mock.On call +// - ctx context.Context +// - config *database.AgentConfig +func (_e *MockAgentConfigStore_Expecter) Update(ctx interface{}, config interface{}) *MockAgentConfigStore_Update_Call { + return &MockAgentConfigStore_Update_Call{Call: _e.mock.On("Update", ctx, config)} +} + +func (_c *MockAgentConfigStore_Update_Call) Run(run func(ctx context.Context, config *database.AgentConfig)) *MockAgentConfigStore_Update_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*database.AgentConfig)) + }) + return _c +} + +func (_c *MockAgentConfigStore_Update_Call) Return(_a0 error) *MockAgentConfigStore_Update_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAgentConfigStore_Update_Call) RunAndReturn(run func(context.Context, *database.AgentConfig) error) *MockAgentConfigStore_Update_Call { + _c.Call.Return(run) + return _c +} + +// NewMockAgentConfigStore creates a new instance of MockAgentConfigStore. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockAgentConfigStore(t interface { + mock.TestingT + Cleanup(func()) +}) *MockAgentConfigStore { + mock := &MockAgentConfigStore{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/_mocks/opencsg.com/csghub-server/component/mock_AgentConfigComponent.go b/_mocks/opencsg.com/csghub-server/component/mock_AgentConfigComponent.go new file mode 100644 index 000000000..f8531108c --- /dev/null +++ b/_mocks/opencsg.com/csghub-server/component/mock_AgentConfigComponent.go @@ -0,0 +1,379 @@ +// Code generated by mockery v2.53.5. DO NOT EDIT. + +package component + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + types "opencsg.com/csghub-server/common/types" +) + +// MockAgentConfigComponent is an autogenerated mock type for the AgentConfigComponent type +type MockAgentConfigComponent struct { + mock.Mock +} + +type MockAgentConfigComponent_Expecter struct { + mock *mock.Mock +} + +func (_m *MockAgentConfigComponent) EXPECT() *MockAgentConfigComponent_Expecter { + return &MockAgentConfigComponent_Expecter{mock: &_m.Mock} +} + +// Create provides a mock function with given fields: ctx, req +func (_m *MockAgentConfigComponent) Create(ctx context.Context, req *types.CreateAgentConfigReq) (*types.AgentConfig, error) { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for Create") + } + + var r0 *types.AgentConfig + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *types.CreateAgentConfigReq) (*types.AgentConfig, error)); ok { + return rf(ctx, req) + } + if rf, ok := ret.Get(0).(func(context.Context, *types.CreateAgentConfigReq) *types.AgentConfig); ok { + r0 = rf(ctx, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.AgentConfig) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *types.CreateAgentConfigReq) error); ok { + r1 = rf(ctx, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAgentConfigComponent_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockAgentConfigComponent_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - req *types.CreateAgentConfigReq +func (_e *MockAgentConfigComponent_Expecter) Create(ctx interface{}, req interface{}) *MockAgentConfigComponent_Create_Call { + return &MockAgentConfigComponent_Create_Call{Call: _e.mock.On("Create", ctx, req)} +} + +func (_c *MockAgentConfigComponent_Create_Call) Run(run func(ctx context.Context, req *types.CreateAgentConfigReq)) *MockAgentConfigComponent_Create_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*types.CreateAgentConfigReq)) + }) + return _c +} + +func (_c *MockAgentConfigComponent_Create_Call) Return(_a0 *types.AgentConfig, _a1 error) *MockAgentConfigComponent_Create_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAgentConfigComponent_Create_Call) RunAndReturn(run func(context.Context, *types.CreateAgentConfigReq) (*types.AgentConfig, error)) *MockAgentConfigComponent_Create_Call { + _c.Call.Return(run) + return _c +} + +// Delete provides a mock function with given fields: ctx, id +func (_m *MockAgentConfigComponent) Delete(ctx context.Context, id int64) error { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for Delete") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, int64) error); ok { + r0 = rf(ctx, id) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockAgentConfigComponent_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' +type MockAgentConfigComponent_Delete_Call struct { + *mock.Call +} + +// Delete is a helper method to define mock.On call +// - ctx context.Context +// - id int64 +func (_e *MockAgentConfigComponent_Expecter) Delete(ctx interface{}, id interface{}) *MockAgentConfigComponent_Delete_Call { + return &MockAgentConfigComponent_Delete_Call{Call: _e.mock.On("Delete", ctx, id)} +} + +func (_c *MockAgentConfigComponent_Delete_Call) Run(run func(ctx context.Context, id int64)) *MockAgentConfigComponent_Delete_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(int64)) + }) + return _c +} + +func (_c *MockAgentConfigComponent_Delete_Call) Return(_a0 error) *MockAgentConfigComponent_Delete_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAgentConfigComponent_Delete_Call) RunAndReturn(run func(context.Context, int64) error) *MockAgentConfigComponent_Delete_Call { + _c.Call.Return(run) + return _c +} + +// GetByID provides a mock function with given fields: ctx, id +func (_m *MockAgentConfigComponent) GetByID(ctx context.Context, id int64) (*types.AgentConfig, error) { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for GetByID") + } + + var r0 *types.AgentConfig + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, int64) (*types.AgentConfig, error)); ok { + return rf(ctx, id) + } + if rf, ok := ret.Get(0).(func(context.Context, int64) *types.AgentConfig); ok { + r0 = rf(ctx, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.AgentConfig) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, int64) error); ok { + r1 = rf(ctx, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAgentConfigComponent_GetByID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByID' +type MockAgentConfigComponent_GetByID_Call struct { + *mock.Call +} + +// GetByID is a helper method to define mock.On call +// - ctx context.Context +// - id int64 +func (_e *MockAgentConfigComponent_Expecter) GetByID(ctx interface{}, id interface{}) *MockAgentConfigComponent_GetByID_Call { + return &MockAgentConfigComponent_GetByID_Call{Call: _e.mock.On("GetByID", ctx, id)} +} + +func (_c *MockAgentConfigComponent_GetByID_Call) Run(run func(ctx context.Context, id int64)) *MockAgentConfigComponent_GetByID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(int64)) + }) + return _c +} + +func (_c *MockAgentConfigComponent_GetByID_Call) Return(_a0 *types.AgentConfig, _a1 error) *MockAgentConfigComponent_GetByID_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAgentConfigComponent_GetByID_Call) RunAndReturn(run func(context.Context, int64) (*types.AgentConfig, error)) *MockAgentConfigComponent_GetByID_Call { + _c.Call.Return(run) + return _c +} + +// GetByName provides a mock function with given fields: ctx, name +func (_m *MockAgentConfigComponent) GetByName(ctx context.Context, name string) (*types.AgentConfig, error) { + ret := _m.Called(ctx, name) + + if len(ret) == 0 { + panic("no return value specified for GetByName") + } + + var r0 *types.AgentConfig + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (*types.AgentConfig, error)); ok { + return rf(ctx, name) + } + if rf, ok := ret.Get(0).(func(context.Context, string) *types.AgentConfig); ok { + r0 = rf(ctx, name) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.AgentConfig) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, name) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAgentConfigComponent_GetByName_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetByName' +type MockAgentConfigComponent_GetByName_Call struct { + *mock.Call +} + +// GetByName is a helper method to define mock.On call +// - ctx context.Context +// - name string +func (_e *MockAgentConfigComponent_Expecter) GetByName(ctx interface{}, name interface{}) *MockAgentConfigComponent_GetByName_Call { + return &MockAgentConfigComponent_GetByName_Call{Call: _e.mock.On("GetByName", ctx, name)} +} + +func (_c *MockAgentConfigComponent_GetByName_Call) Run(run func(ctx context.Context, name string)) *MockAgentConfigComponent_GetByName_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockAgentConfigComponent_GetByName_Call) Return(_a0 *types.AgentConfig, _a1 error) *MockAgentConfigComponent_GetByName_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAgentConfigComponent_GetByName_Call) RunAndReturn(run func(context.Context, string) (*types.AgentConfig, error)) *MockAgentConfigComponent_GetByName_Call { + _c.Call.Return(run) + return _c +} + +// List provides a mock function with given fields: ctx +func (_m *MockAgentConfigComponent) List(ctx context.Context) ([]*types.AgentConfig, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for List") + } + + var r0 []*types.AgentConfig + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) ([]*types.AgentConfig, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) []*types.AgentConfig); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*types.AgentConfig) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAgentConfigComponent_List_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'List' +type MockAgentConfigComponent_List_Call struct { + *mock.Call +} + +// List is a helper method to define mock.On call +// - ctx context.Context +func (_e *MockAgentConfigComponent_Expecter) List(ctx interface{}) *MockAgentConfigComponent_List_Call { + return &MockAgentConfigComponent_List_Call{Call: _e.mock.On("List", ctx)} +} + +func (_c *MockAgentConfigComponent_List_Call) Run(run func(ctx context.Context)) *MockAgentConfigComponent_List_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *MockAgentConfigComponent_List_Call) Return(_a0 []*types.AgentConfig, _a1 error) *MockAgentConfigComponent_List_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAgentConfigComponent_List_Call) RunAndReturn(run func(context.Context) ([]*types.AgentConfig, error)) *MockAgentConfigComponent_List_Call { + _c.Call.Return(run) + return _c +} + +// Update provides a mock function with given fields: ctx, id, req +func (_m *MockAgentConfigComponent) Update(ctx context.Context, id int64, req *types.UpdateAgentConfigReq) (*types.AgentConfig, error) { + ret := _m.Called(ctx, id, req) + + if len(ret) == 0 { + panic("no return value specified for Update") + } + + var r0 *types.AgentConfig + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, int64, *types.UpdateAgentConfigReq) (*types.AgentConfig, error)); ok { + return rf(ctx, id, req) + } + if rf, ok := ret.Get(0).(func(context.Context, int64, *types.UpdateAgentConfigReq) *types.AgentConfig); ok { + r0 = rf(ctx, id, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.AgentConfig) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, int64, *types.UpdateAgentConfigReq) error); ok { + r1 = rf(ctx, id, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAgentConfigComponent_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' +type MockAgentConfigComponent_Update_Call struct { + *mock.Call +} + +// Update is a helper method to define mock.On call +// - ctx context.Context +// - id int64 +// - req *types.UpdateAgentConfigReq +func (_e *MockAgentConfigComponent_Expecter) Update(ctx interface{}, id interface{}, req interface{}) *MockAgentConfigComponent_Update_Call { + return &MockAgentConfigComponent_Update_Call{Call: _e.mock.On("Update", ctx, id, req)} +} + +func (_c *MockAgentConfigComponent_Update_Call) Run(run func(ctx context.Context, id int64, req *types.UpdateAgentConfigReq)) *MockAgentConfigComponent_Update_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(int64), args[2].(*types.UpdateAgentConfigReq)) + }) + return _c +} + +func (_c *MockAgentConfigComponent_Update_Call) Return(_a0 *types.AgentConfig, _a1 error) *MockAgentConfigComponent_Update_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAgentConfigComponent_Update_Call) RunAndReturn(run func(context.Context, int64, *types.UpdateAgentConfigReq) (*types.AgentConfig, error)) *MockAgentConfigComponent_Update_Call { + _c.Call.Return(run) + return _c +} + +// NewMockAgentConfigComponent creates a new instance of MockAgentConfigComponent. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockAgentConfigComponent(t interface { + mock.TestingT + Cleanup(func()) +}) *MockAgentConfigComponent { + mock := &MockAgentConfigComponent{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/_mocks/opencsg.com/csghub-server/component/mock_AgentInstanceAdapter.go b/_mocks/opencsg.com/csghub-server/component/mock_AgentInstanceAdapter.go new file mode 100644 index 000000000..d0cf796a8 --- /dev/null +++ b/_mocks/opencsg.com/csghub-server/component/mock_AgentInstanceAdapter.go @@ -0,0 +1,417 @@ +// Code generated by mockery v2.53.5. DO NOT EDIT. + +package component + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + database "opencsg.com/csghub-server/builder/store/database" + + types "opencsg.com/csghub-server/common/types" +) + +// MockAgentInstanceAdapter is an autogenerated mock type for the AgentInstanceAdapter type +type MockAgentInstanceAdapter struct { + mock.Mock +} + +type MockAgentInstanceAdapter_Expecter struct { + mock *mock.Mock +} + +func (_m *MockAgentInstanceAdapter) EXPECT() *MockAgentInstanceAdapter_Expecter { + return &MockAgentInstanceAdapter_Expecter{mock: &_m.Mock} +} + +// CreateInstance provides a mock function with given fields: ctx, userUUID, instance, template +func (_m *MockAgentInstanceAdapter) CreateInstance(ctx context.Context, userUUID string, instance *types.AgentInstance, template *database.AgentTemplate) (*types.AgentInstanceCreationResult, error) { + ret := _m.Called(ctx, userUUID, instance, template) + + if len(ret) == 0 { + panic("no return value specified for CreateInstance") + } + + var r0 *types.AgentInstanceCreationResult + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, *types.AgentInstance, *database.AgentTemplate) (*types.AgentInstanceCreationResult, error)); ok { + return rf(ctx, userUUID, instance, template) + } + if rf, ok := ret.Get(0).(func(context.Context, string, *types.AgentInstance, *database.AgentTemplate) *types.AgentInstanceCreationResult); ok { + r0 = rf(ctx, userUUID, instance, template) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.AgentInstanceCreationResult) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, *types.AgentInstance, *database.AgentTemplate) error); ok { + r1 = rf(ctx, userUUID, instance, template) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAgentInstanceAdapter_CreateInstance_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateInstance' +type MockAgentInstanceAdapter_CreateInstance_Call struct { + *mock.Call +} + +// CreateInstance is a helper method to define mock.On call +// - ctx context.Context +// - userUUID string +// - instance *types.AgentInstance +// - template *database.AgentTemplate +func (_e *MockAgentInstanceAdapter_Expecter) CreateInstance(ctx interface{}, userUUID interface{}, instance interface{}, template interface{}) *MockAgentInstanceAdapter_CreateInstance_Call { + return &MockAgentInstanceAdapter_CreateInstance_Call{Call: _e.mock.On("CreateInstance", ctx, userUUID, instance, template)} +} + +func (_c *MockAgentInstanceAdapter_CreateInstance_Call) Run(run func(ctx context.Context, userUUID string, instance *types.AgentInstance, template *database.AgentTemplate)) *MockAgentInstanceAdapter_CreateInstance_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(*types.AgentInstance), args[3].(*database.AgentTemplate)) + }) + return _c +} + +func (_c *MockAgentInstanceAdapter_CreateInstance_Call) Return(_a0 *types.AgentInstanceCreationResult, _a1 error) *MockAgentInstanceAdapter_CreateInstance_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAgentInstanceAdapter_CreateInstance_Call) RunAndReturn(run func(context.Context, string, *types.AgentInstance, *database.AgentTemplate) (*types.AgentInstanceCreationResult, error)) *MockAgentInstanceAdapter_CreateInstance_Call { + _c.Call.Return(run) + return _c +} + +// DeleteInstance provides a mock function with given fields: ctx, userUUID, contentID +func (_m *MockAgentInstanceAdapter) DeleteInstance(ctx context.Context, userUUID string, contentID string) error { + ret := _m.Called(ctx, userUUID, contentID) + + if len(ret) == 0 { + panic("no return value specified for DeleteInstance") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok { + r0 = rf(ctx, userUUID, contentID) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockAgentInstanceAdapter_DeleteInstance_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteInstance' +type MockAgentInstanceAdapter_DeleteInstance_Call struct { + *mock.Call +} + +// DeleteInstance is a helper method to define mock.On call +// - ctx context.Context +// - userUUID string +// - contentID string +func (_e *MockAgentInstanceAdapter_Expecter) DeleteInstance(ctx interface{}, userUUID interface{}, contentID interface{}) *MockAgentInstanceAdapter_DeleteInstance_Call { + return &MockAgentInstanceAdapter_DeleteInstance_Call{Call: _e.mock.On("DeleteInstance", ctx, userUUID, contentID)} +} + +func (_c *MockAgentInstanceAdapter_DeleteInstance_Call) Run(run func(ctx context.Context, userUUID string, contentID string)) *MockAgentInstanceAdapter_DeleteInstance_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string)) + }) + return _c +} + +func (_c *MockAgentInstanceAdapter_DeleteInstance_Call) Return(_a0 error) *MockAgentInstanceAdapter_DeleteInstance_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAgentInstanceAdapter_DeleteInstance_Call) RunAndReturn(run func(context.Context, string, string) error) *MockAgentInstanceAdapter_DeleteInstance_Call { + _c.Call.Return(run) + return _c +} + +// GetInstanceType provides a mock function with no fields +func (_m *MockAgentInstanceAdapter) GetInstanceType() string { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GetInstanceType") + } + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// MockAgentInstanceAdapter_GetInstanceType_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetInstanceType' +type MockAgentInstanceAdapter_GetInstanceType_Call struct { + *mock.Call +} + +// GetInstanceType is a helper method to define mock.On call +func (_e *MockAgentInstanceAdapter_Expecter) GetInstanceType() *MockAgentInstanceAdapter_GetInstanceType_Call { + return &MockAgentInstanceAdapter_GetInstanceType_Call{Call: _e.mock.On("GetInstanceType")} +} + +func (_c *MockAgentInstanceAdapter_GetInstanceType_Call) Run(run func()) *MockAgentInstanceAdapter_GetInstanceType_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockAgentInstanceAdapter_GetInstanceType_Call) Return(_a0 string) *MockAgentInstanceAdapter_GetInstanceType_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAgentInstanceAdapter_GetInstanceType_Call) RunAndReturn(run func() string) *MockAgentInstanceAdapter_GetInstanceType_Call { + _c.Call.Return(run) + return _c +} + +// GetQuotaPerUser provides a mock function with given fields: ctx +func (_m *MockAgentInstanceAdapter) GetQuotaPerUser(ctx context.Context) (int, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for GetQuotaPerUser") + } + + var r0 int + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) (int, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) int); ok { + r0 = rf(ctx) + } else { + r0 = ret.Get(0).(int) + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAgentInstanceAdapter_GetQuotaPerUser_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetQuotaPerUser' +type MockAgentInstanceAdapter_GetQuotaPerUser_Call struct { + *mock.Call +} + +// GetQuotaPerUser is a helper method to define mock.On call +// - ctx context.Context +func (_e *MockAgentInstanceAdapter_Expecter) GetQuotaPerUser(ctx interface{}) *MockAgentInstanceAdapter_GetQuotaPerUser_Call { + return &MockAgentInstanceAdapter_GetQuotaPerUser_Call{Call: _e.mock.On("GetQuotaPerUser", ctx)} +} + +func (_c *MockAgentInstanceAdapter_GetQuotaPerUser_Call) Run(run func(ctx context.Context)) *MockAgentInstanceAdapter_GetQuotaPerUser_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *MockAgentInstanceAdapter_GetQuotaPerUser_Call) Return(_a0 int, _a1 error) *MockAgentInstanceAdapter_GetQuotaPerUser_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAgentInstanceAdapter_GetQuotaPerUser_Call) RunAndReturn(run func(context.Context) (int, error)) *MockAgentInstanceAdapter_GetQuotaPerUser_Call { + _c.Call.Return(run) + return _c +} + +// IsInstanceRunning provides a mock function with given fields: ctx, userUUID, contentID, builtIn +func (_m *MockAgentInstanceAdapter) IsInstanceRunning(ctx context.Context, userUUID string, contentID string, builtIn bool) (bool, error) { + ret := _m.Called(ctx, userUUID, contentID, builtIn) + + if len(ret) == 0 { + panic("no return value specified for IsInstanceRunning") + } + + var r0 bool + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, bool) (bool, error)); ok { + return rf(ctx, userUUID, contentID, builtIn) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, bool) bool); ok { + r0 = rf(ctx, userUUID, contentID, builtIn) + } else { + r0 = ret.Get(0).(bool) + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, bool) error); ok { + r1 = rf(ctx, userUUID, contentID, builtIn) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAgentInstanceAdapter_IsInstanceRunning_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsInstanceRunning' +type MockAgentInstanceAdapter_IsInstanceRunning_Call struct { + *mock.Call +} + +// IsInstanceRunning is a helper method to define mock.On call +// - ctx context.Context +// - userUUID string +// - contentID string +// - builtIn bool +func (_e *MockAgentInstanceAdapter_Expecter) IsInstanceRunning(ctx interface{}, userUUID interface{}, contentID interface{}, builtIn interface{}) *MockAgentInstanceAdapter_IsInstanceRunning_Call { + return &MockAgentInstanceAdapter_IsInstanceRunning_Call{Call: _e.mock.On("IsInstanceRunning", ctx, userUUID, contentID, builtIn)} +} + +func (_c *MockAgentInstanceAdapter_IsInstanceRunning_Call) Run(run func(ctx context.Context, userUUID string, contentID string, builtIn bool)) *MockAgentInstanceAdapter_IsInstanceRunning_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(bool)) + }) + return _c +} + +func (_c *MockAgentInstanceAdapter_IsInstanceRunning_Call) Return(_a0 bool, _a1 error) *MockAgentInstanceAdapter_IsInstanceRunning_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAgentInstanceAdapter_IsInstanceRunning_Call) RunAndReturn(run func(context.Context, string, string, bool) (bool, error)) *MockAgentInstanceAdapter_IsInstanceRunning_Call { + _c.Call.Return(run) + return _c +} + +// Status provides a mock function with given fields: ctx, userUUID, contentIDs, builtInMap +func (_m *MockAgentInstanceAdapter) Status(ctx context.Context, userUUID string, contentIDs []string, builtInMap map[string]bool) ([]types.AgentInstanceStatusResult, error) { + ret := _m.Called(ctx, userUUID, contentIDs, builtInMap) + + if len(ret) == 0 { + panic("no return value specified for Status") + } + + var r0 []types.AgentInstanceStatusResult + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, []string, map[string]bool) ([]types.AgentInstanceStatusResult, error)); ok { + return rf(ctx, userUUID, contentIDs, builtInMap) + } + if rf, ok := ret.Get(0).(func(context.Context, string, []string, map[string]bool) []types.AgentInstanceStatusResult); ok { + r0 = rf(ctx, userUUID, contentIDs, builtInMap) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]types.AgentInstanceStatusResult) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, []string, map[string]bool) error); ok { + r1 = rf(ctx, userUUID, contentIDs, builtInMap) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAgentInstanceAdapter_Status_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Status' +type MockAgentInstanceAdapter_Status_Call struct { + *mock.Call +} + +// Status is a helper method to define mock.On call +// - ctx context.Context +// - userUUID string +// - contentIDs []string +// - builtInMap map[string]bool +func (_e *MockAgentInstanceAdapter_Expecter) Status(ctx interface{}, userUUID interface{}, contentIDs interface{}, builtInMap interface{}) *MockAgentInstanceAdapter_Status_Call { + return &MockAgentInstanceAdapter_Status_Call{Call: _e.mock.On("Status", ctx, userUUID, contentIDs, builtInMap)} +} + +func (_c *MockAgentInstanceAdapter_Status_Call) Run(run func(ctx context.Context, userUUID string, contentIDs []string, builtInMap map[string]bool)) *MockAgentInstanceAdapter_Status_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].([]string), args[3].(map[string]bool)) + }) + return _c +} + +func (_c *MockAgentInstanceAdapter_Status_Call) Return(_a0 []types.AgentInstanceStatusResult, _a1 error) *MockAgentInstanceAdapter_Status_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAgentInstanceAdapter_Status_Call) RunAndReturn(run func(context.Context, string, []string, map[string]bool) ([]types.AgentInstanceStatusResult, error)) *MockAgentInstanceAdapter_Status_Call { + _c.Call.Return(run) + return _c +} + +// UpdateInstance provides a mock function with given fields: ctx, userUUID, instance +func (_m *MockAgentInstanceAdapter) UpdateInstance(ctx context.Context, userUUID string, instance *types.AgentInstance) error { + ret := _m.Called(ctx, userUUID, instance) + + if len(ret) == 0 { + panic("no return value specified for UpdateInstance") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, *types.AgentInstance) error); ok { + r0 = rf(ctx, userUUID, instance) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockAgentInstanceAdapter_UpdateInstance_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateInstance' +type MockAgentInstanceAdapter_UpdateInstance_Call struct { + *mock.Call +} + +// UpdateInstance is a helper method to define mock.On call +// - ctx context.Context +// - userUUID string +// - instance *types.AgentInstance +func (_e *MockAgentInstanceAdapter_Expecter) UpdateInstance(ctx interface{}, userUUID interface{}, instance interface{}) *MockAgentInstanceAdapter_UpdateInstance_Call { + return &MockAgentInstanceAdapter_UpdateInstance_Call{Call: _e.mock.On("UpdateInstance", ctx, userUUID, instance)} +} + +func (_c *MockAgentInstanceAdapter_UpdateInstance_Call) Run(run func(ctx context.Context, userUUID string, instance *types.AgentInstance)) *MockAgentInstanceAdapter_UpdateInstance_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(*types.AgentInstance)) + }) + return _c +} + +func (_c *MockAgentInstanceAdapter_UpdateInstance_Call) Return(_a0 error) *MockAgentInstanceAdapter_UpdateInstance_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAgentInstanceAdapter_UpdateInstance_Call) RunAndReturn(run func(context.Context, string, *types.AgentInstance) error) *MockAgentInstanceAdapter_UpdateInstance_Call { + _c.Call.Return(run) + return _c +} + +// NewMockAgentInstanceAdapter creates a new instance of MockAgentInstanceAdapter. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockAgentInstanceAdapter(t interface { + mock.TestingT + Cleanup(func()) +}) *MockAgentInstanceAdapter { + mock := &MockAgentInstanceAdapter{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/_mocks/opencsg.com/csghub-server/component/mock_AgentInstanceComponent.go b/_mocks/opencsg.com/csghub-server/component/mock_AgentInstanceComponent.go new file mode 100644 index 000000000..9f582949c --- /dev/null +++ b/_mocks/opencsg.com/csghub-server/component/mock_AgentInstanceComponent.go @@ -0,0 +1,1212 @@ +// Code generated by mockery v2.53.5. DO NOT EDIT. + +package component + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + types "opencsg.com/csghub-server/common/types" +) + +// MockAgentInstanceComponent is an autogenerated mock type for the AgentInstanceComponent type +type MockAgentInstanceComponent struct { + mock.Mock +} + +type MockAgentInstanceComponent_Expecter struct { + mock *mock.Mock +} + +func (_m *MockAgentInstanceComponent) EXPECT() *MockAgentInstanceComponent_Expecter { + return &MockAgentInstanceComponent_Expecter{mock: &_m.Mock} +} + +// CreateInstance provides a mock function with given fields: ctx, instance +func (_m *MockAgentInstanceComponent) CreateInstance(ctx context.Context, instance *types.AgentInstance) error { + ret := _m.Called(ctx, instance) + + if len(ret) == 0 { + panic("no return value specified for CreateInstance") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, *types.AgentInstance) error); ok { + r0 = rf(ctx, instance) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockAgentInstanceComponent_CreateInstance_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateInstance' +type MockAgentInstanceComponent_CreateInstance_Call struct { + *mock.Call +} + +// CreateInstance is a helper method to define mock.On call +// - ctx context.Context +// - instance *types.AgentInstance +func (_e *MockAgentInstanceComponent_Expecter) CreateInstance(ctx interface{}, instance interface{}) *MockAgentInstanceComponent_CreateInstance_Call { + return &MockAgentInstanceComponent_CreateInstance_Call{Call: _e.mock.On("CreateInstance", ctx, instance)} +} + +func (_c *MockAgentInstanceComponent_CreateInstance_Call) Run(run func(ctx context.Context, instance *types.AgentInstance)) *MockAgentInstanceComponent_CreateInstance_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*types.AgentInstance)) + }) + return _c +} + +func (_c *MockAgentInstanceComponent_CreateInstance_Call) Return(_a0 error) *MockAgentInstanceComponent_CreateInstance_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAgentInstanceComponent_CreateInstance_Call) RunAndReturn(run func(context.Context, *types.AgentInstance) error) *MockAgentInstanceComponent_CreateInstance_Call { + _c.Call.Return(run) + return _c +} + +// CreateSession provides a mock function with given fields: ctx, userUUID, req +func (_m *MockAgentInstanceComponent) CreateSession(ctx context.Context, userUUID string, req *types.CreateAgentInstanceSessionRequest) (string, error) { + ret := _m.Called(ctx, userUUID, req) + + if len(ret) == 0 { + panic("no return value specified for CreateSession") + } + + var r0 string + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, *types.CreateAgentInstanceSessionRequest) (string, error)); ok { + return rf(ctx, userUUID, req) + } + if rf, ok := ret.Get(0).(func(context.Context, string, *types.CreateAgentInstanceSessionRequest) string); ok { + r0 = rf(ctx, userUUID, req) + } else { + r0 = ret.Get(0).(string) + } + + if rf, ok := ret.Get(1).(func(context.Context, string, *types.CreateAgentInstanceSessionRequest) error); ok { + r1 = rf(ctx, userUUID, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAgentInstanceComponent_CreateSession_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateSession' +type MockAgentInstanceComponent_CreateSession_Call struct { + *mock.Call +} + +// CreateSession is a helper method to define mock.On call +// - ctx context.Context +// - userUUID string +// - req *types.CreateAgentInstanceSessionRequest +func (_e *MockAgentInstanceComponent_Expecter) CreateSession(ctx interface{}, userUUID interface{}, req interface{}) *MockAgentInstanceComponent_CreateSession_Call { + return &MockAgentInstanceComponent_CreateSession_Call{Call: _e.mock.On("CreateSession", ctx, userUUID, req)} +} + +func (_c *MockAgentInstanceComponent_CreateSession_Call) Run(run func(ctx context.Context, userUUID string, req *types.CreateAgentInstanceSessionRequest)) *MockAgentInstanceComponent_CreateSession_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(*types.CreateAgentInstanceSessionRequest)) + }) + return _c +} + +func (_c *MockAgentInstanceComponent_CreateSession_Call) Return(sessionUUID string, err error) *MockAgentInstanceComponent_CreateSession_Call { + _c.Call.Return(sessionUUID, err) + return _c +} + +func (_c *MockAgentInstanceComponent_CreateSession_Call) RunAndReturn(run func(context.Context, string, *types.CreateAgentInstanceSessionRequest) (string, error)) *MockAgentInstanceComponent_CreateSession_Call { + _c.Call.Return(run) + return _c +} + +// CreateSessionHistories provides a mock function with given fields: ctx, userUUID, instanceID, req +func (_m *MockAgentInstanceComponent) CreateSessionHistories(ctx context.Context, userUUID string, instanceID int64, req *types.CreateSessionHistoryRequest) (*types.CreateSessionHistoryResponse, error) { + ret := _m.Called(ctx, userUUID, instanceID, req) + + if len(ret) == 0 { + panic("no return value specified for CreateSessionHistories") + } + + var r0 *types.CreateSessionHistoryResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, int64, *types.CreateSessionHistoryRequest) (*types.CreateSessionHistoryResponse, error)); ok { + return rf(ctx, userUUID, instanceID, req) + } + if rf, ok := ret.Get(0).(func(context.Context, string, int64, *types.CreateSessionHistoryRequest) *types.CreateSessionHistoryResponse); ok { + r0 = rf(ctx, userUUID, instanceID, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.CreateSessionHistoryResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, int64, *types.CreateSessionHistoryRequest) error); ok { + r1 = rf(ctx, userUUID, instanceID, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAgentInstanceComponent_CreateSessionHistories_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateSessionHistories' +type MockAgentInstanceComponent_CreateSessionHistories_Call struct { + *mock.Call +} + +// CreateSessionHistories is a helper method to define mock.On call +// - ctx context.Context +// - userUUID string +// - instanceID int64 +// - req *types.CreateSessionHistoryRequest +func (_e *MockAgentInstanceComponent_Expecter) CreateSessionHistories(ctx interface{}, userUUID interface{}, instanceID interface{}, req interface{}) *MockAgentInstanceComponent_CreateSessionHistories_Call { + return &MockAgentInstanceComponent_CreateSessionHistories_Call{Call: _e.mock.On("CreateSessionHistories", ctx, userUUID, instanceID, req)} +} + +func (_c *MockAgentInstanceComponent_CreateSessionHistories_Call) Run(run func(ctx context.Context, userUUID string, instanceID int64, req *types.CreateSessionHistoryRequest)) *MockAgentInstanceComponent_CreateSessionHistories_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(int64), args[3].(*types.CreateSessionHistoryRequest)) + }) + return _c +} + +func (_c *MockAgentInstanceComponent_CreateSessionHistories_Call) Return(_a0 *types.CreateSessionHistoryResponse, _a1 error) *MockAgentInstanceComponent_CreateSessionHistories_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAgentInstanceComponent_CreateSessionHistories_Call) RunAndReturn(run func(context.Context, string, int64, *types.CreateSessionHistoryRequest) (*types.CreateSessionHistoryResponse, error)) *MockAgentInstanceComponent_CreateSessionHistories_Call { + _c.Call.Return(run) + return _c +} + +// DeleteInstance provides a mock function with given fields: ctx, id, userUUID +func (_m *MockAgentInstanceComponent) DeleteInstance(ctx context.Context, id int64, userUUID string) error { + ret := _m.Called(ctx, id, userUUID) + + if len(ret) == 0 { + panic("no return value specified for DeleteInstance") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, int64, string) error); ok { + r0 = rf(ctx, id, userUUID) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockAgentInstanceComponent_DeleteInstance_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteInstance' +type MockAgentInstanceComponent_DeleteInstance_Call struct { + *mock.Call +} + +// DeleteInstance is a helper method to define mock.On call +// - ctx context.Context +// - id int64 +// - userUUID string +func (_e *MockAgentInstanceComponent_Expecter) DeleteInstance(ctx interface{}, id interface{}, userUUID interface{}) *MockAgentInstanceComponent_DeleteInstance_Call { + return &MockAgentInstanceComponent_DeleteInstance_Call{Call: _e.mock.On("DeleteInstance", ctx, id, userUUID)} +} + +func (_c *MockAgentInstanceComponent_DeleteInstance_Call) Run(run func(ctx context.Context, id int64, userUUID string)) *MockAgentInstanceComponent_DeleteInstance_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(int64), args[2].(string)) + }) + return _c +} + +func (_c *MockAgentInstanceComponent_DeleteInstance_Call) Return(_a0 error) *MockAgentInstanceComponent_DeleteInstance_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAgentInstanceComponent_DeleteInstance_Call) RunAndReturn(run func(context.Context, int64, string) error) *MockAgentInstanceComponent_DeleteInstance_Call { + _c.Call.Return(run) + return _c +} + +// DeleteInstanceByContentID provides a mock function with given fields: ctx, userUUID, instanceType, instanceContentID +func (_m *MockAgentInstanceComponent) DeleteInstanceByContentID(ctx context.Context, userUUID string, instanceType string, instanceContentID string) error { + ret := _m.Called(ctx, userUUID, instanceType, instanceContentID) + + if len(ret) == 0 { + panic("no return value specified for DeleteInstanceByContentID") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) error); ok { + r0 = rf(ctx, userUUID, instanceType, instanceContentID) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockAgentInstanceComponent_DeleteInstanceByContentID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteInstanceByContentID' +type MockAgentInstanceComponent_DeleteInstanceByContentID_Call struct { + *mock.Call +} + +// DeleteInstanceByContentID is a helper method to define mock.On call +// - ctx context.Context +// - userUUID string +// - instanceType string +// - instanceContentID string +func (_e *MockAgentInstanceComponent_Expecter) DeleteInstanceByContentID(ctx interface{}, userUUID interface{}, instanceType interface{}, instanceContentID interface{}) *MockAgentInstanceComponent_DeleteInstanceByContentID_Call { + return &MockAgentInstanceComponent_DeleteInstanceByContentID_Call{Call: _e.mock.On("DeleteInstanceByContentID", ctx, userUUID, instanceType, instanceContentID)} +} + +func (_c *MockAgentInstanceComponent_DeleteInstanceByContentID_Call) Run(run func(ctx context.Context, userUUID string, instanceType string, instanceContentID string)) *MockAgentInstanceComponent_DeleteInstanceByContentID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) + }) + return _c +} + +func (_c *MockAgentInstanceComponent_DeleteInstanceByContentID_Call) Return(_a0 error) *MockAgentInstanceComponent_DeleteInstanceByContentID_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAgentInstanceComponent_DeleteInstanceByContentID_Call) RunAndReturn(run func(context.Context, string, string, string) error) *MockAgentInstanceComponent_DeleteInstanceByContentID_Call { + _c.Call.Return(run) + return _c +} + +// DeleteSessionByUUID provides a mock function with given fields: ctx, userUUID, sessionUUID, instanceID +func (_m *MockAgentInstanceComponent) DeleteSessionByUUID(ctx context.Context, userUUID string, sessionUUID string, instanceID int64) error { + ret := _m.Called(ctx, userUUID, sessionUUID, instanceID) + + if len(ret) == 0 { + panic("no return value specified for DeleteSessionByUUID") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, int64) error); ok { + r0 = rf(ctx, userUUID, sessionUUID, instanceID) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockAgentInstanceComponent_DeleteSessionByUUID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteSessionByUUID' +type MockAgentInstanceComponent_DeleteSessionByUUID_Call struct { + *mock.Call +} + +// DeleteSessionByUUID is a helper method to define mock.On call +// - ctx context.Context +// - userUUID string +// - sessionUUID string +// - instanceID int64 +func (_e *MockAgentInstanceComponent_Expecter) DeleteSessionByUUID(ctx interface{}, userUUID interface{}, sessionUUID interface{}, instanceID interface{}) *MockAgentInstanceComponent_DeleteSessionByUUID_Call { + return &MockAgentInstanceComponent_DeleteSessionByUUID_Call{Call: _e.mock.On("DeleteSessionByUUID", ctx, userUUID, sessionUUID, instanceID)} +} + +func (_c *MockAgentInstanceComponent_DeleteSessionByUUID_Call) Run(run func(ctx context.Context, userUUID string, sessionUUID string, instanceID int64)) *MockAgentInstanceComponent_DeleteSessionByUUID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(int64)) + }) + return _c +} + +func (_c *MockAgentInstanceComponent_DeleteSessionByUUID_Call) Return(_a0 error) *MockAgentInstanceComponent_DeleteSessionByUUID_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAgentInstanceComponent_DeleteSessionByUUID_Call) RunAndReturn(run func(context.Context, string, string, int64) error) *MockAgentInstanceComponent_DeleteSessionByUUID_Call { + _c.Call.Return(run) + return _c +} + +// GetInstanceByID provides a mock function with given fields: ctx, id, userUUID +func (_m *MockAgentInstanceComponent) GetInstanceByID(ctx context.Context, id int64, userUUID string) (*types.AgentInstance, error) { + ret := _m.Called(ctx, id, userUUID) + + if len(ret) == 0 { + panic("no return value specified for GetInstanceByID") + } + + var r0 *types.AgentInstance + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, int64, string) (*types.AgentInstance, error)); ok { + return rf(ctx, id, userUUID) + } + if rf, ok := ret.Get(0).(func(context.Context, int64, string) *types.AgentInstance); ok { + r0 = rf(ctx, id, userUUID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.AgentInstance) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, int64, string) error); ok { + r1 = rf(ctx, id, userUUID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAgentInstanceComponent_GetInstanceByID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetInstanceByID' +type MockAgentInstanceComponent_GetInstanceByID_Call struct { + *mock.Call +} + +// GetInstanceByID is a helper method to define mock.On call +// - ctx context.Context +// - id int64 +// - userUUID string +func (_e *MockAgentInstanceComponent_Expecter) GetInstanceByID(ctx interface{}, id interface{}, userUUID interface{}) *MockAgentInstanceComponent_GetInstanceByID_Call { + return &MockAgentInstanceComponent_GetInstanceByID_Call{Call: _e.mock.On("GetInstanceByID", ctx, id, userUUID)} +} + +func (_c *MockAgentInstanceComponent_GetInstanceByID_Call) Run(run func(ctx context.Context, id int64, userUUID string)) *MockAgentInstanceComponent_GetInstanceByID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(int64), args[2].(string)) + }) + return _c +} + +func (_c *MockAgentInstanceComponent_GetInstanceByID_Call) Return(_a0 *types.AgentInstance, _a1 error) *MockAgentInstanceComponent_GetInstanceByID_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAgentInstanceComponent_GetInstanceByID_Call) RunAndReturn(run func(context.Context, int64, string) (*types.AgentInstance, error)) *MockAgentInstanceComponent_GetInstanceByID_Call { + _c.Call.Return(run) + return _c +} + +// GetInstancesStatus provides a mock function with given fields: ctx, userUUID, instanceIDs +func (_m *MockAgentInstanceComponent) GetInstancesStatus(ctx context.Context, userUUID string, instanceIDs []int64) ([]types.AgentInstanceStatusResponse, error) { + ret := _m.Called(ctx, userUUID, instanceIDs) + + if len(ret) == 0 { + panic("no return value specified for GetInstancesStatus") + } + + var r0 []types.AgentInstanceStatusResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, []int64) ([]types.AgentInstanceStatusResponse, error)); ok { + return rf(ctx, userUUID, instanceIDs) + } + if rf, ok := ret.Get(0).(func(context.Context, string, []int64) []types.AgentInstanceStatusResponse); ok { + r0 = rf(ctx, userUUID, instanceIDs) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]types.AgentInstanceStatusResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, []int64) error); ok { + r1 = rf(ctx, userUUID, instanceIDs) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAgentInstanceComponent_GetInstancesStatus_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetInstancesStatus' +type MockAgentInstanceComponent_GetInstancesStatus_Call struct { + *mock.Call +} + +// GetInstancesStatus is a helper method to define mock.On call +// - ctx context.Context +// - userUUID string +// - instanceIDs []int64 +func (_e *MockAgentInstanceComponent_Expecter) GetInstancesStatus(ctx interface{}, userUUID interface{}, instanceIDs interface{}) *MockAgentInstanceComponent_GetInstancesStatus_Call { + return &MockAgentInstanceComponent_GetInstancesStatus_Call{Call: _e.mock.On("GetInstancesStatus", ctx, userUUID, instanceIDs)} +} + +func (_c *MockAgentInstanceComponent_GetInstancesStatus_Call) Run(run func(ctx context.Context, userUUID string, instanceIDs []int64)) *MockAgentInstanceComponent_GetInstancesStatus_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].([]int64)) + }) + return _c +} + +func (_c *MockAgentInstanceComponent_GetInstancesStatus_Call) Return(_a0 []types.AgentInstanceStatusResponse, _a1 error) *MockAgentInstanceComponent_GetInstancesStatus_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAgentInstanceComponent_GetInstancesStatus_Call) RunAndReturn(run func(context.Context, string, []int64) ([]types.AgentInstanceStatusResponse, error)) *MockAgentInstanceComponent_GetInstancesStatus_Call { + _c.Call.Return(run) + return _c +} + +// GetMonitor provides a mock function with given fields: ctx, monitorID +func (_m *MockAgentInstanceComponent) GetMonitor(ctx context.Context, monitorID string) ([]int64, error) { + ret := _m.Called(ctx, monitorID) + + if len(ret) == 0 { + panic("no return value specified for GetMonitor") + } + + var r0 []int64 + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) ([]int64, error)); ok { + return rf(ctx, monitorID) + } + if rf, ok := ret.Get(0).(func(context.Context, string) []int64); ok { + r0 = rf(ctx, monitorID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]int64) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, monitorID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAgentInstanceComponent_GetMonitor_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetMonitor' +type MockAgentInstanceComponent_GetMonitor_Call struct { + *mock.Call +} + +// GetMonitor is a helper method to define mock.On call +// - ctx context.Context +// - monitorID string +func (_e *MockAgentInstanceComponent_Expecter) GetMonitor(ctx interface{}, monitorID interface{}) *MockAgentInstanceComponent_GetMonitor_Call { + return &MockAgentInstanceComponent_GetMonitor_Call{Call: _e.mock.On("GetMonitor", ctx, monitorID)} +} + +func (_c *MockAgentInstanceComponent_GetMonitor_Call) Run(run func(ctx context.Context, monitorID string)) *MockAgentInstanceComponent_GetMonitor_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockAgentInstanceComponent_GetMonitor_Call) Return(_a0 []int64, _a1 error) *MockAgentInstanceComponent_GetMonitor_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAgentInstanceComponent_GetMonitor_Call) RunAndReturn(run func(context.Context, string) ([]int64, error)) *MockAgentInstanceComponent_GetMonitor_Call { + _c.Call.Return(run) + return _c +} + +// GetSessionByUUID provides a mock function with given fields: ctx, userUUID, sessionUUID, instanceID +func (_m *MockAgentInstanceComponent) GetSessionByUUID(ctx context.Context, userUUID string, sessionUUID string, instanceID int64) (*types.AgentInstanceSession, error) { + ret := _m.Called(ctx, userUUID, sessionUUID, instanceID) + + if len(ret) == 0 { + panic("no return value specified for GetSessionByUUID") + } + + var r0 *types.AgentInstanceSession + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, int64) (*types.AgentInstanceSession, error)); ok { + return rf(ctx, userUUID, sessionUUID, instanceID) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, int64) *types.AgentInstanceSession); ok { + r0 = rf(ctx, userUUID, sessionUUID, instanceID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.AgentInstanceSession) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, int64) error); ok { + r1 = rf(ctx, userUUID, sessionUUID, instanceID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAgentInstanceComponent_GetSessionByUUID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSessionByUUID' +type MockAgentInstanceComponent_GetSessionByUUID_Call struct { + *mock.Call +} + +// GetSessionByUUID is a helper method to define mock.On call +// - ctx context.Context +// - userUUID string +// - sessionUUID string +// - instanceID int64 +func (_e *MockAgentInstanceComponent_Expecter) GetSessionByUUID(ctx interface{}, userUUID interface{}, sessionUUID interface{}, instanceID interface{}) *MockAgentInstanceComponent_GetSessionByUUID_Call { + return &MockAgentInstanceComponent_GetSessionByUUID_Call{Call: _e.mock.On("GetSessionByUUID", ctx, userUUID, sessionUUID, instanceID)} +} + +func (_c *MockAgentInstanceComponent_GetSessionByUUID_Call) Run(run func(ctx context.Context, userUUID string, sessionUUID string, instanceID int64)) *MockAgentInstanceComponent_GetSessionByUUID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(int64)) + }) + return _c +} + +func (_c *MockAgentInstanceComponent_GetSessionByUUID_Call) Return(_a0 *types.AgentInstanceSession, _a1 error) *MockAgentInstanceComponent_GetSessionByUUID_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAgentInstanceComponent_GetSessionByUUID_Call) RunAndReturn(run func(context.Context, string, string, int64) (*types.AgentInstanceSession, error)) *MockAgentInstanceComponent_GetSessionByUUID_Call { + _c.Call.Return(run) + return _c +} + +// IsInstanceExistsByContentID provides a mock function with given fields: ctx, instanceType, instanceContentID +func (_m *MockAgentInstanceComponent) IsInstanceExistsByContentID(ctx context.Context, instanceType string, instanceContentID string) (bool, error) { + ret := _m.Called(ctx, instanceType, instanceContentID) + + if len(ret) == 0 { + panic("no return value specified for IsInstanceExistsByContentID") + } + + var r0 bool + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string) (bool, error)); ok { + return rf(ctx, instanceType, instanceContentID) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string) bool); ok { + r0 = rf(ctx, instanceType, instanceContentID) + } else { + r0 = ret.Get(0).(bool) + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { + r1 = rf(ctx, instanceType, instanceContentID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAgentInstanceComponent_IsInstanceExistsByContentID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsInstanceExistsByContentID' +type MockAgentInstanceComponent_IsInstanceExistsByContentID_Call struct { + *mock.Call +} + +// IsInstanceExistsByContentID is a helper method to define mock.On call +// - ctx context.Context +// - instanceType string +// - instanceContentID string +func (_e *MockAgentInstanceComponent_Expecter) IsInstanceExistsByContentID(ctx interface{}, instanceType interface{}, instanceContentID interface{}) *MockAgentInstanceComponent_IsInstanceExistsByContentID_Call { + return &MockAgentInstanceComponent_IsInstanceExistsByContentID_Call{Call: _e.mock.On("IsInstanceExistsByContentID", ctx, instanceType, instanceContentID)} +} + +func (_c *MockAgentInstanceComponent_IsInstanceExistsByContentID_Call) Run(run func(ctx context.Context, instanceType string, instanceContentID string)) *MockAgentInstanceComponent_IsInstanceExistsByContentID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string)) + }) + return _c +} + +func (_c *MockAgentInstanceComponent_IsInstanceExistsByContentID_Call) Return(_a0 bool, _a1 error) *MockAgentInstanceComponent_IsInstanceExistsByContentID_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAgentInstanceComponent_IsInstanceExistsByContentID_Call) RunAndReturn(run func(context.Context, string, string) (bool, error)) *MockAgentInstanceComponent_IsInstanceExistsByContentID_Call { + _c.Call.Return(run) + return _c +} + +// ListInstancesByUserUUID provides a mock function with given fields: ctx, userUUID, filter, per, page +func (_m *MockAgentInstanceComponent) ListInstancesByUserUUID(ctx context.Context, userUUID string, filter types.AgentInstanceFilter, per int, page int) ([]*types.AgentInstance, int, error) { + ret := _m.Called(ctx, userUUID, filter, per, page) + + if len(ret) == 0 { + panic("no return value specified for ListInstancesByUserUUID") + } + + var r0 []*types.AgentInstance + var r1 int + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string, types.AgentInstanceFilter, int, int) ([]*types.AgentInstance, int, error)); ok { + return rf(ctx, userUUID, filter, per, page) + } + if rf, ok := ret.Get(0).(func(context.Context, string, types.AgentInstanceFilter, int, int) []*types.AgentInstance); ok { + r0 = rf(ctx, userUUID, filter, per, page) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*types.AgentInstance) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, types.AgentInstanceFilter, int, int) int); ok { + r1 = rf(ctx, userUUID, filter, per, page) + } else { + r1 = ret.Get(1).(int) + } + + if rf, ok := ret.Get(2).(func(context.Context, string, types.AgentInstanceFilter, int, int) error); ok { + r2 = rf(ctx, userUUID, filter, per, page) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockAgentInstanceComponent_ListInstancesByUserUUID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListInstancesByUserUUID' +type MockAgentInstanceComponent_ListInstancesByUserUUID_Call struct { + *mock.Call +} + +// ListInstancesByUserUUID is a helper method to define mock.On call +// - ctx context.Context +// - userUUID string +// - filter types.AgentInstanceFilter +// - per int +// - page int +func (_e *MockAgentInstanceComponent_Expecter) ListInstancesByUserUUID(ctx interface{}, userUUID interface{}, filter interface{}, per interface{}, page interface{}) *MockAgentInstanceComponent_ListInstancesByUserUUID_Call { + return &MockAgentInstanceComponent_ListInstancesByUserUUID_Call{Call: _e.mock.On("ListInstancesByUserUUID", ctx, userUUID, filter, per, page)} +} + +func (_c *MockAgentInstanceComponent_ListInstancesByUserUUID_Call) Run(run func(ctx context.Context, userUUID string, filter types.AgentInstanceFilter, per int, page int)) *MockAgentInstanceComponent_ListInstancesByUserUUID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(types.AgentInstanceFilter), args[3].(int), args[4].(int)) + }) + return _c +} + +func (_c *MockAgentInstanceComponent_ListInstancesByUserUUID_Call) Return(_a0 []*types.AgentInstance, _a1 int, _a2 error) *MockAgentInstanceComponent_ListInstancesByUserUUID_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockAgentInstanceComponent_ListInstancesByUserUUID_Call) RunAndReturn(run func(context.Context, string, types.AgentInstanceFilter, int, int) ([]*types.AgentInstance, int, error)) *MockAgentInstanceComponent_ListInstancesByUserUUID_Call { + _c.Call.Return(run) + return _c +} + +// ListSessionHistories provides a mock function with given fields: ctx, userUUID, sessionUUID, instanceID +func (_m *MockAgentInstanceComponent) ListSessionHistories(ctx context.Context, userUUID string, sessionUUID string, instanceID int64) ([]*types.AgentInstanceSessionHistory, error) { + ret := _m.Called(ctx, userUUID, sessionUUID, instanceID) + + if len(ret) == 0 { + panic("no return value specified for ListSessionHistories") + } + + var r0 []*types.AgentInstanceSessionHistory + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, int64) ([]*types.AgentInstanceSessionHistory, error)); ok { + return rf(ctx, userUUID, sessionUUID, instanceID) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, int64) []*types.AgentInstanceSessionHistory); ok { + r0 = rf(ctx, userUUID, sessionUUID, instanceID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*types.AgentInstanceSessionHistory) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, int64) error); ok { + r1 = rf(ctx, userUUID, sessionUUID, instanceID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAgentInstanceComponent_ListSessionHistories_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListSessionHistories' +type MockAgentInstanceComponent_ListSessionHistories_Call struct { + *mock.Call +} + +// ListSessionHistories is a helper method to define mock.On call +// - ctx context.Context +// - userUUID string +// - sessionUUID string +// - instanceID int64 +func (_e *MockAgentInstanceComponent_Expecter) ListSessionHistories(ctx interface{}, userUUID interface{}, sessionUUID interface{}, instanceID interface{}) *MockAgentInstanceComponent_ListSessionHistories_Call { + return &MockAgentInstanceComponent_ListSessionHistories_Call{Call: _e.mock.On("ListSessionHistories", ctx, userUUID, sessionUUID, instanceID)} +} + +func (_c *MockAgentInstanceComponent_ListSessionHistories_Call) Run(run func(ctx context.Context, userUUID string, sessionUUID string, instanceID int64)) *MockAgentInstanceComponent_ListSessionHistories_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(int64)) + }) + return _c +} + +func (_c *MockAgentInstanceComponent_ListSessionHistories_Call) Return(_a0 []*types.AgentInstanceSessionHistory, _a1 error) *MockAgentInstanceComponent_ListSessionHistories_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAgentInstanceComponent_ListSessionHistories_Call) RunAndReturn(run func(context.Context, string, string, int64) ([]*types.AgentInstanceSessionHistory, error)) *MockAgentInstanceComponent_ListSessionHistories_Call { + _c.Call.Return(run) + return _c +} + +// ListSessions provides a mock function with given fields: ctx, userUUID, filter, per, page +func (_m *MockAgentInstanceComponent) ListSessions(ctx context.Context, userUUID string, filter types.AgentInstanceSessionFilter, per int, page int) ([]*types.AgentInstanceSession, int, error) { + ret := _m.Called(ctx, userUUID, filter, per, page) + + if len(ret) == 0 { + panic("no return value specified for ListSessions") + } + + var r0 []*types.AgentInstanceSession + var r1 int + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string, types.AgentInstanceSessionFilter, int, int) ([]*types.AgentInstanceSession, int, error)); ok { + return rf(ctx, userUUID, filter, per, page) + } + if rf, ok := ret.Get(0).(func(context.Context, string, types.AgentInstanceSessionFilter, int, int) []*types.AgentInstanceSession); ok { + r0 = rf(ctx, userUUID, filter, per, page) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*types.AgentInstanceSession) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, types.AgentInstanceSessionFilter, int, int) int); ok { + r1 = rf(ctx, userUUID, filter, per, page) + } else { + r1 = ret.Get(1).(int) + } + + if rf, ok := ret.Get(2).(func(context.Context, string, types.AgentInstanceSessionFilter, int, int) error); ok { + r2 = rf(ctx, userUUID, filter, per, page) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockAgentInstanceComponent_ListSessions_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListSessions' +type MockAgentInstanceComponent_ListSessions_Call struct { + *mock.Call +} + +// ListSessions is a helper method to define mock.On call +// - ctx context.Context +// - userUUID string +// - filter types.AgentInstanceSessionFilter +// - per int +// - page int +func (_e *MockAgentInstanceComponent_Expecter) ListSessions(ctx interface{}, userUUID interface{}, filter interface{}, per interface{}, page interface{}) *MockAgentInstanceComponent_ListSessions_Call { + return &MockAgentInstanceComponent_ListSessions_Call{Call: _e.mock.On("ListSessions", ctx, userUUID, filter, per, page)} +} + +func (_c *MockAgentInstanceComponent_ListSessions_Call) Run(run func(ctx context.Context, userUUID string, filter types.AgentInstanceSessionFilter, per int, page int)) *MockAgentInstanceComponent_ListSessions_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(types.AgentInstanceSessionFilter), args[3].(int), args[4].(int)) + }) + return _c +} + +func (_c *MockAgentInstanceComponent_ListSessions_Call) Return(_a0 []*types.AgentInstanceSession, _a1 int, _a2 error) *MockAgentInstanceComponent_ListSessions_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockAgentInstanceComponent_ListSessions_Call) RunAndReturn(run func(context.Context, string, types.AgentInstanceSessionFilter, int, int) ([]*types.AgentInstanceSession, int, error)) *MockAgentInstanceComponent_ListSessions_Call { + _c.Call.Return(run) + return _c +} + +// RefreshMonitor provides a mock function with given fields: ctx, monitorID +func (_m *MockAgentInstanceComponent) RefreshMonitor(ctx context.Context, monitorID string) error { + ret := _m.Called(ctx, monitorID) + + if len(ret) == 0 { + panic("no return value specified for RefreshMonitor") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string) error); ok { + r0 = rf(ctx, monitorID) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockAgentInstanceComponent_RefreshMonitor_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RefreshMonitor' +type MockAgentInstanceComponent_RefreshMonitor_Call struct { + *mock.Call +} + +// RefreshMonitor is a helper method to define mock.On call +// - ctx context.Context +// - monitorID string +func (_e *MockAgentInstanceComponent_Expecter) RefreshMonitor(ctx interface{}, monitorID interface{}) *MockAgentInstanceComponent_RefreshMonitor_Call { + return &MockAgentInstanceComponent_RefreshMonitor_Call{Call: _e.mock.On("RefreshMonitor", ctx, monitorID)} +} + +func (_c *MockAgentInstanceComponent_RefreshMonitor_Call) Run(run func(ctx context.Context, monitorID string)) *MockAgentInstanceComponent_RefreshMonitor_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockAgentInstanceComponent_RefreshMonitor_Call) Return(_a0 error) *MockAgentInstanceComponent_RefreshMonitor_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAgentInstanceComponent_RefreshMonitor_Call) RunAndReturn(run func(context.Context, string) error) *MockAgentInstanceComponent_RefreshMonitor_Call { + _c.Call.Return(run) + return _c +} + +// RewriteSessionHistory provides a mock function with given fields: ctx, userUUID, instanceID, sessionUUID, req +func (_m *MockAgentInstanceComponent) RewriteSessionHistory(ctx context.Context, userUUID string, instanceID int64, sessionUUID string, req *types.RewriteSessionHistoryRequest) (*types.RewriteSessionHistoryResponse, error) { + ret := _m.Called(ctx, userUUID, instanceID, sessionUUID, req) + + if len(ret) == 0 { + panic("no return value specified for RewriteSessionHistory") + } + + var r0 *types.RewriteSessionHistoryResponse + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, int64, string, *types.RewriteSessionHistoryRequest) (*types.RewriteSessionHistoryResponse, error)); ok { + return rf(ctx, userUUID, instanceID, sessionUUID, req) + } + if rf, ok := ret.Get(0).(func(context.Context, string, int64, string, *types.RewriteSessionHistoryRequest) *types.RewriteSessionHistoryResponse); ok { + r0 = rf(ctx, userUUID, instanceID, sessionUUID, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.RewriteSessionHistoryResponse) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, int64, string, *types.RewriteSessionHistoryRequest) error); ok { + r1 = rf(ctx, userUUID, instanceID, sessionUUID, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAgentInstanceComponent_RewriteSessionHistory_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'RewriteSessionHistory' +type MockAgentInstanceComponent_RewriteSessionHistory_Call struct { + *mock.Call +} + +// RewriteSessionHistory is a helper method to define mock.On call +// - ctx context.Context +// - userUUID string +// - instanceID int64 +// - sessionUUID string +// - req *types.RewriteSessionHistoryRequest +func (_e *MockAgentInstanceComponent_Expecter) RewriteSessionHistory(ctx interface{}, userUUID interface{}, instanceID interface{}, sessionUUID interface{}, req interface{}) *MockAgentInstanceComponent_RewriteSessionHistory_Call { + return &MockAgentInstanceComponent_RewriteSessionHistory_Call{Call: _e.mock.On("RewriteSessionHistory", ctx, userUUID, instanceID, sessionUUID, req)} +} + +func (_c *MockAgentInstanceComponent_RewriteSessionHistory_Call) Run(run func(ctx context.Context, userUUID string, instanceID int64, sessionUUID string, req *types.RewriteSessionHistoryRequest)) *MockAgentInstanceComponent_RewriteSessionHistory_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(int64), args[3].(string), args[4].(*types.RewriteSessionHistoryRequest)) + }) + return _c +} + +func (_c *MockAgentInstanceComponent_RewriteSessionHistory_Call) Return(_a0 *types.RewriteSessionHistoryResponse, _a1 error) *MockAgentInstanceComponent_RewriteSessionHistory_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAgentInstanceComponent_RewriteSessionHistory_Call) RunAndReturn(run func(context.Context, string, int64, string, *types.RewriteSessionHistoryRequest) (*types.RewriteSessionHistoryResponse, error)) *MockAgentInstanceComponent_RewriteSessionHistory_Call { + _c.Call.Return(run) + return _c +} + +// SetMonitor provides a mock function with given fields: ctx, userUUID, request +func (_m *MockAgentInstanceComponent) SetMonitor(ctx context.Context, userUUID string, request types.AgentMonitorRequest) error { + ret := _m.Called(ctx, userUUID, request) + + if len(ret) == 0 { + panic("no return value specified for SetMonitor") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, types.AgentMonitorRequest) error); ok { + r0 = rf(ctx, userUUID, request) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockAgentInstanceComponent_SetMonitor_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetMonitor' +type MockAgentInstanceComponent_SetMonitor_Call struct { + *mock.Call +} + +// SetMonitor is a helper method to define mock.On call +// - ctx context.Context +// - userUUID string +// - request types.AgentMonitorRequest +func (_e *MockAgentInstanceComponent_Expecter) SetMonitor(ctx interface{}, userUUID interface{}, request interface{}) *MockAgentInstanceComponent_SetMonitor_Call { + return &MockAgentInstanceComponent_SetMonitor_Call{Call: _e.mock.On("SetMonitor", ctx, userUUID, request)} +} + +func (_c *MockAgentInstanceComponent_SetMonitor_Call) Run(run func(ctx context.Context, userUUID string, request types.AgentMonitorRequest)) *MockAgentInstanceComponent_SetMonitor_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(types.AgentMonitorRequest)) + }) + return _c +} + +func (_c *MockAgentInstanceComponent_SetMonitor_Call) Return(_a0 error) *MockAgentInstanceComponent_SetMonitor_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAgentInstanceComponent_SetMonitor_Call) RunAndReturn(run func(context.Context, string, types.AgentMonitorRequest) error) *MockAgentInstanceComponent_SetMonitor_Call { + _c.Call.Return(run) + return _c +} + +// UpdateInstance provides a mock function with given fields: ctx, instance +func (_m *MockAgentInstanceComponent) UpdateInstance(ctx context.Context, instance *types.AgentInstance) error { + ret := _m.Called(ctx, instance) + + if len(ret) == 0 { + panic("no return value specified for UpdateInstance") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, *types.AgentInstance) error); ok { + r0 = rf(ctx, instance) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockAgentInstanceComponent_UpdateInstance_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateInstance' +type MockAgentInstanceComponent_UpdateInstance_Call struct { + *mock.Call +} + +// UpdateInstance is a helper method to define mock.On call +// - ctx context.Context +// - instance *types.AgentInstance +func (_e *MockAgentInstanceComponent_Expecter) UpdateInstance(ctx interface{}, instance interface{}) *MockAgentInstanceComponent_UpdateInstance_Call { + return &MockAgentInstanceComponent_UpdateInstance_Call{Call: _e.mock.On("UpdateInstance", ctx, instance)} +} + +func (_c *MockAgentInstanceComponent_UpdateInstance_Call) Run(run func(ctx context.Context, instance *types.AgentInstance)) *MockAgentInstanceComponent_UpdateInstance_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*types.AgentInstance)) + }) + return _c +} + +func (_c *MockAgentInstanceComponent_UpdateInstance_Call) Return(_a0 error) *MockAgentInstanceComponent_UpdateInstance_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAgentInstanceComponent_UpdateInstance_Call) RunAndReturn(run func(context.Context, *types.AgentInstance) error) *MockAgentInstanceComponent_UpdateInstance_Call { + _c.Call.Return(run) + return _c +} + +// UpdateInstanceByContentID provides a mock function with given fields: ctx, userUUID, instanceType, instanceContentID, updateRequest +func (_m *MockAgentInstanceComponent) UpdateInstanceByContentID(ctx context.Context, userUUID string, instanceType string, instanceContentID string, updateRequest types.UpdateAgentInstanceRequest) (*types.AgentInstance, error) { + ret := _m.Called(ctx, userUUID, instanceType, instanceContentID, updateRequest) + + if len(ret) == 0 { + panic("no return value specified for UpdateInstanceByContentID") + } + + var r0 *types.AgentInstance + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, types.UpdateAgentInstanceRequest) (*types.AgentInstance, error)); ok { + return rf(ctx, userUUID, instanceType, instanceContentID, updateRequest) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string, types.UpdateAgentInstanceRequest) *types.AgentInstance); ok { + r0 = rf(ctx, userUUID, instanceType, instanceContentID, updateRequest) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.AgentInstance) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string, types.UpdateAgentInstanceRequest) error); ok { + r1 = rf(ctx, userUUID, instanceType, instanceContentID, updateRequest) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAgentInstanceComponent_UpdateInstanceByContentID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateInstanceByContentID' +type MockAgentInstanceComponent_UpdateInstanceByContentID_Call struct { + *mock.Call +} + +// UpdateInstanceByContentID is a helper method to define mock.On call +// - ctx context.Context +// - userUUID string +// - instanceType string +// - instanceContentID string +// - updateRequest types.UpdateAgentInstanceRequest +func (_e *MockAgentInstanceComponent_Expecter) UpdateInstanceByContentID(ctx interface{}, userUUID interface{}, instanceType interface{}, instanceContentID interface{}, updateRequest interface{}) *MockAgentInstanceComponent_UpdateInstanceByContentID_Call { + return &MockAgentInstanceComponent_UpdateInstanceByContentID_Call{Call: _e.mock.On("UpdateInstanceByContentID", ctx, userUUID, instanceType, instanceContentID, updateRequest)} +} + +func (_c *MockAgentInstanceComponent_UpdateInstanceByContentID_Call) Run(run func(ctx context.Context, userUUID string, instanceType string, instanceContentID string, updateRequest types.UpdateAgentInstanceRequest)) *MockAgentInstanceComponent_UpdateInstanceByContentID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string), args[4].(types.UpdateAgentInstanceRequest)) + }) + return _c +} + +func (_c *MockAgentInstanceComponent_UpdateInstanceByContentID_Call) Return(_a0 *types.AgentInstance, _a1 error) *MockAgentInstanceComponent_UpdateInstanceByContentID_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAgentInstanceComponent_UpdateInstanceByContentID_Call) RunAndReturn(run func(context.Context, string, string, string, types.UpdateAgentInstanceRequest) (*types.AgentInstance, error)) *MockAgentInstanceComponent_UpdateInstanceByContentID_Call { + _c.Call.Return(run) + return _c +} + +// UpdateSessionByUUID provides a mock function with given fields: ctx, userUUID, sessionUUID, instanceID, req +func (_m *MockAgentInstanceComponent) UpdateSessionByUUID(ctx context.Context, userUUID string, sessionUUID string, instanceID int64, req *types.UpdateAgentInstanceSessionRequest) error { + ret := _m.Called(ctx, userUUID, sessionUUID, instanceID, req) + + if len(ret) == 0 { + panic("no return value specified for UpdateSessionByUUID") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, int64, *types.UpdateAgentInstanceSessionRequest) error); ok { + r0 = rf(ctx, userUUID, sessionUUID, instanceID, req) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockAgentInstanceComponent_UpdateSessionByUUID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateSessionByUUID' +type MockAgentInstanceComponent_UpdateSessionByUUID_Call struct { + *mock.Call +} + +// UpdateSessionByUUID is a helper method to define mock.On call +// - ctx context.Context +// - userUUID string +// - sessionUUID string +// - instanceID int64 +// - req *types.UpdateAgentInstanceSessionRequest +func (_e *MockAgentInstanceComponent_Expecter) UpdateSessionByUUID(ctx interface{}, userUUID interface{}, sessionUUID interface{}, instanceID interface{}, req interface{}) *MockAgentInstanceComponent_UpdateSessionByUUID_Call { + return &MockAgentInstanceComponent_UpdateSessionByUUID_Call{Call: _e.mock.On("UpdateSessionByUUID", ctx, userUUID, sessionUUID, instanceID, req)} +} + +func (_c *MockAgentInstanceComponent_UpdateSessionByUUID_Call) Run(run func(ctx context.Context, userUUID string, sessionUUID string, instanceID int64, req *types.UpdateAgentInstanceSessionRequest)) *MockAgentInstanceComponent_UpdateSessionByUUID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(int64), args[4].(*types.UpdateAgentInstanceSessionRequest)) + }) + return _c +} + +func (_c *MockAgentInstanceComponent_UpdateSessionByUUID_Call) Return(_a0 error) *MockAgentInstanceComponent_UpdateSessionByUUID_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAgentInstanceComponent_UpdateSessionByUUID_Call) RunAndReturn(run func(context.Context, string, string, int64, *types.UpdateAgentInstanceSessionRequest) error) *MockAgentInstanceComponent_UpdateSessionByUUID_Call { + _c.Call.Return(run) + return _c +} + +// UpdateSessionHistoryFeedback provides a mock function with given fields: ctx, userUUID, instanceID, sessionUUID, req +func (_m *MockAgentInstanceComponent) UpdateSessionHistoryFeedback(ctx context.Context, userUUID string, instanceID int64, sessionUUID string, req *types.FeedbackSessionHistoryRequest) error { + ret := _m.Called(ctx, userUUID, instanceID, sessionUUID, req) + + if len(ret) == 0 { + panic("no return value specified for UpdateSessionHistoryFeedback") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, int64, string, *types.FeedbackSessionHistoryRequest) error); ok { + r0 = rf(ctx, userUUID, instanceID, sessionUUID, req) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockAgentInstanceComponent_UpdateSessionHistoryFeedback_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateSessionHistoryFeedback' +type MockAgentInstanceComponent_UpdateSessionHistoryFeedback_Call struct { + *mock.Call +} + +// UpdateSessionHistoryFeedback is a helper method to define mock.On call +// - ctx context.Context +// - userUUID string +// - instanceID int64 +// - sessionUUID string +// - req *types.FeedbackSessionHistoryRequest +func (_e *MockAgentInstanceComponent_Expecter) UpdateSessionHistoryFeedback(ctx interface{}, userUUID interface{}, instanceID interface{}, sessionUUID interface{}, req interface{}) *MockAgentInstanceComponent_UpdateSessionHistoryFeedback_Call { + return &MockAgentInstanceComponent_UpdateSessionHistoryFeedback_Call{Call: _e.mock.On("UpdateSessionHistoryFeedback", ctx, userUUID, instanceID, sessionUUID, req)} +} + +func (_c *MockAgentInstanceComponent_UpdateSessionHistoryFeedback_Call) Run(run func(ctx context.Context, userUUID string, instanceID int64, sessionUUID string, req *types.FeedbackSessionHistoryRequest)) *MockAgentInstanceComponent_UpdateSessionHistoryFeedback_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(int64), args[3].(string), args[4].(*types.FeedbackSessionHistoryRequest)) + }) + return _c +} + +func (_c *MockAgentInstanceComponent_UpdateSessionHistoryFeedback_Call) Return(_a0 error) *MockAgentInstanceComponent_UpdateSessionHistoryFeedback_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAgentInstanceComponent_UpdateSessionHistoryFeedback_Call) RunAndReturn(run func(context.Context, string, int64, string, *types.FeedbackSessionHistoryRequest) error) *MockAgentInstanceComponent_UpdateSessionHistoryFeedback_Call { + _c.Call.Return(run) + return _c +} + +// NewMockAgentInstanceComponent creates a new instance of MockAgentInstanceComponent. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockAgentInstanceComponent(t interface { + mock.TestingT + Cleanup(func()) +}) *MockAgentInstanceComponent { + mock := &MockAgentInstanceComponent{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/_mocks/opencsg.com/csghub-server/component/mock_AgentKnowledgeBaseComponent.go b/_mocks/opencsg.com/csghub-server/component/mock_AgentKnowledgeBaseComponent.go new file mode 100644 index 000000000..0f2a5ed22 --- /dev/null +++ b/_mocks/opencsg.com/csghub-server/component/mock_AgentKnowledgeBaseComponent.go @@ -0,0 +1,536 @@ +// Code generated by mockery v2.53.5. DO NOT EDIT. + +package component + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + types "opencsg.com/csghub-server/common/types" +) + +// MockAgentKnowledgeBaseComponent is an autogenerated mock type for the AgentKnowledgeBaseComponent type +type MockAgentKnowledgeBaseComponent struct { + mock.Mock +} + +type MockAgentKnowledgeBaseComponent_Expecter struct { + mock *mock.Mock +} + +func (_m *MockAgentKnowledgeBaseComponent) EXPECT() *MockAgentKnowledgeBaseComponent_Expecter { + return &MockAgentKnowledgeBaseComponent_Expecter{mock: &_m.Mock} +} + +// CreateKnowledgeBase provides a mock function with given fields: ctx, req +func (_m *MockAgentKnowledgeBaseComponent) CreateKnowledgeBase(ctx context.Context, req *types.CreateAgentKnowledgeBaseReq) (*types.AgentKnowledgeBase, error) { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for CreateKnowledgeBase") + } + + var r0 *types.AgentKnowledgeBase + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *types.CreateAgentKnowledgeBaseReq) (*types.AgentKnowledgeBase, error)); ok { + return rf(ctx, req) + } + if rf, ok := ret.Get(0).(func(context.Context, *types.CreateAgentKnowledgeBaseReq) *types.AgentKnowledgeBase); ok { + r0 = rf(ctx, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.AgentKnowledgeBase) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *types.CreateAgentKnowledgeBaseReq) error); ok { + r1 = rf(ctx, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAgentKnowledgeBaseComponent_CreateKnowledgeBase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateKnowledgeBase' +type MockAgentKnowledgeBaseComponent_CreateKnowledgeBase_Call struct { + *mock.Call +} + +// CreateKnowledgeBase is a helper method to define mock.On call +// - ctx context.Context +// - req *types.CreateAgentKnowledgeBaseReq +func (_e *MockAgentKnowledgeBaseComponent_Expecter) CreateKnowledgeBase(ctx interface{}, req interface{}) *MockAgentKnowledgeBaseComponent_CreateKnowledgeBase_Call { + return &MockAgentKnowledgeBaseComponent_CreateKnowledgeBase_Call{Call: _e.mock.On("CreateKnowledgeBase", ctx, req)} +} + +func (_c *MockAgentKnowledgeBaseComponent_CreateKnowledgeBase_Call) Run(run func(ctx context.Context, req *types.CreateAgentKnowledgeBaseReq)) *MockAgentKnowledgeBaseComponent_CreateKnowledgeBase_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*types.CreateAgentKnowledgeBaseReq)) + }) + return _c +} + +func (_c *MockAgentKnowledgeBaseComponent_CreateKnowledgeBase_Call) Return(_a0 *types.AgentKnowledgeBase, _a1 error) *MockAgentKnowledgeBaseComponent_CreateKnowledgeBase_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAgentKnowledgeBaseComponent_CreateKnowledgeBase_Call) RunAndReturn(run func(context.Context, *types.CreateAgentKnowledgeBaseReq) (*types.AgentKnowledgeBase, error)) *MockAgentKnowledgeBaseComponent_CreateKnowledgeBase_Call { + _c.Call.Return(run) + return _c +} + +// DeleteKnowledgeBase provides a mock function with given fields: ctx, id, userUUID +func (_m *MockAgentKnowledgeBaseComponent) DeleteKnowledgeBase(ctx context.Context, id int64, userUUID string) error { + ret := _m.Called(ctx, id, userUUID) + + if len(ret) == 0 { + panic("no return value specified for DeleteKnowledgeBase") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, int64, string) error); ok { + r0 = rf(ctx, id, userUUID) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockAgentKnowledgeBaseComponent_DeleteKnowledgeBase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteKnowledgeBase' +type MockAgentKnowledgeBaseComponent_DeleteKnowledgeBase_Call struct { + *mock.Call +} + +// DeleteKnowledgeBase is a helper method to define mock.On call +// - ctx context.Context +// - id int64 +// - userUUID string +func (_e *MockAgentKnowledgeBaseComponent_Expecter) DeleteKnowledgeBase(ctx interface{}, id interface{}, userUUID interface{}) *MockAgentKnowledgeBaseComponent_DeleteKnowledgeBase_Call { + return &MockAgentKnowledgeBaseComponent_DeleteKnowledgeBase_Call{Call: _e.mock.On("DeleteKnowledgeBase", ctx, id, userUUID)} +} + +func (_c *MockAgentKnowledgeBaseComponent_DeleteKnowledgeBase_Call) Run(run func(ctx context.Context, id int64, userUUID string)) *MockAgentKnowledgeBaseComponent_DeleteKnowledgeBase_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(int64), args[2].(string)) + }) + return _c +} + +func (_c *MockAgentKnowledgeBaseComponent_DeleteKnowledgeBase_Call) Return(_a0 error) *MockAgentKnowledgeBaseComponent_DeleteKnowledgeBase_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAgentKnowledgeBaseComponent_DeleteKnowledgeBase_Call) RunAndReturn(run func(context.Context, int64, string) error) *MockAgentKnowledgeBaseComponent_DeleteKnowledgeBase_Call { + _c.Call.Return(run) + return _c +} + +// DeleteKnowledgeBaseByContentID provides a mock function with given fields: ctx, contentID, userUUID +func (_m *MockAgentKnowledgeBaseComponent) DeleteKnowledgeBaseByContentID(ctx context.Context, contentID string, userUUID string) error { + ret := _m.Called(ctx, contentID, userUUID) + + if len(ret) == 0 { + panic("no return value specified for DeleteKnowledgeBaseByContentID") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok { + r0 = rf(ctx, contentID, userUUID) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockAgentKnowledgeBaseComponent_DeleteKnowledgeBaseByContentID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteKnowledgeBaseByContentID' +type MockAgentKnowledgeBaseComponent_DeleteKnowledgeBaseByContentID_Call struct { + *mock.Call +} + +// DeleteKnowledgeBaseByContentID is a helper method to define mock.On call +// - ctx context.Context +// - contentID string +// - userUUID string +func (_e *MockAgentKnowledgeBaseComponent_Expecter) DeleteKnowledgeBaseByContentID(ctx interface{}, contentID interface{}, userUUID interface{}) *MockAgentKnowledgeBaseComponent_DeleteKnowledgeBaseByContentID_Call { + return &MockAgentKnowledgeBaseComponent_DeleteKnowledgeBaseByContentID_Call{Call: _e.mock.On("DeleteKnowledgeBaseByContentID", ctx, contentID, userUUID)} +} + +func (_c *MockAgentKnowledgeBaseComponent_DeleteKnowledgeBaseByContentID_Call) Run(run func(ctx context.Context, contentID string, userUUID string)) *MockAgentKnowledgeBaseComponent_DeleteKnowledgeBaseByContentID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string)) + }) + return _c +} + +func (_c *MockAgentKnowledgeBaseComponent_DeleteKnowledgeBaseByContentID_Call) Return(_a0 error) *MockAgentKnowledgeBaseComponent_DeleteKnowledgeBaseByContentID_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAgentKnowledgeBaseComponent_DeleteKnowledgeBaseByContentID_Call) RunAndReturn(run func(context.Context, string, string) error) *MockAgentKnowledgeBaseComponent_DeleteKnowledgeBaseByContentID_Call { + _c.Call.Return(run) + return _c +} + +// GetKnowledgeBaseByContentID provides a mock function with given fields: ctx, contentID, userUUID +func (_m *MockAgentKnowledgeBaseComponent) GetKnowledgeBaseByContentID(ctx context.Context, contentID string, userUUID string) (*types.AgentKnowledgeBaseDetail, error) { + ret := _m.Called(ctx, contentID, userUUID) + + if len(ret) == 0 { + panic("no return value specified for GetKnowledgeBaseByContentID") + } + + var r0 *types.AgentKnowledgeBaseDetail + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string) (*types.AgentKnowledgeBaseDetail, error)); ok { + return rf(ctx, contentID, userUUID) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string) *types.AgentKnowledgeBaseDetail); ok { + r0 = rf(ctx, contentID, userUUID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.AgentKnowledgeBaseDetail) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { + r1 = rf(ctx, contentID, userUUID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAgentKnowledgeBaseComponent_GetKnowledgeBaseByContentID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetKnowledgeBaseByContentID' +type MockAgentKnowledgeBaseComponent_GetKnowledgeBaseByContentID_Call struct { + *mock.Call +} + +// GetKnowledgeBaseByContentID is a helper method to define mock.On call +// - ctx context.Context +// - contentID string +// - userUUID string +func (_e *MockAgentKnowledgeBaseComponent_Expecter) GetKnowledgeBaseByContentID(ctx interface{}, contentID interface{}, userUUID interface{}) *MockAgentKnowledgeBaseComponent_GetKnowledgeBaseByContentID_Call { + return &MockAgentKnowledgeBaseComponent_GetKnowledgeBaseByContentID_Call{Call: _e.mock.On("GetKnowledgeBaseByContentID", ctx, contentID, userUUID)} +} + +func (_c *MockAgentKnowledgeBaseComponent_GetKnowledgeBaseByContentID_Call) Run(run func(ctx context.Context, contentID string, userUUID string)) *MockAgentKnowledgeBaseComponent_GetKnowledgeBaseByContentID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string)) + }) + return _c +} + +func (_c *MockAgentKnowledgeBaseComponent_GetKnowledgeBaseByContentID_Call) Return(_a0 *types.AgentKnowledgeBaseDetail, _a1 error) *MockAgentKnowledgeBaseComponent_GetKnowledgeBaseByContentID_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAgentKnowledgeBaseComponent_GetKnowledgeBaseByContentID_Call) RunAndReturn(run func(context.Context, string, string) (*types.AgentKnowledgeBaseDetail, error)) *MockAgentKnowledgeBaseComponent_GetKnowledgeBaseByContentID_Call { + _c.Call.Return(run) + return _c +} + +// GetKnowledgeBaseByID provides a mock function with given fields: ctx, id, userUUID +func (_m *MockAgentKnowledgeBaseComponent) GetKnowledgeBaseByID(ctx context.Context, id int64, userUUID string) (*types.AgentKnowledgeBaseDetail, error) { + ret := _m.Called(ctx, id, userUUID) + + if len(ret) == 0 { + panic("no return value specified for GetKnowledgeBaseByID") + } + + var r0 *types.AgentKnowledgeBaseDetail + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, int64, string) (*types.AgentKnowledgeBaseDetail, error)); ok { + return rf(ctx, id, userUUID) + } + if rf, ok := ret.Get(0).(func(context.Context, int64, string) *types.AgentKnowledgeBaseDetail); ok { + r0 = rf(ctx, id, userUUID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.AgentKnowledgeBaseDetail) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, int64, string) error); ok { + r1 = rf(ctx, id, userUUID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAgentKnowledgeBaseComponent_GetKnowledgeBaseByID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetKnowledgeBaseByID' +type MockAgentKnowledgeBaseComponent_GetKnowledgeBaseByID_Call struct { + *mock.Call +} + +// GetKnowledgeBaseByID is a helper method to define mock.On call +// - ctx context.Context +// - id int64 +// - userUUID string +func (_e *MockAgentKnowledgeBaseComponent_Expecter) GetKnowledgeBaseByID(ctx interface{}, id interface{}, userUUID interface{}) *MockAgentKnowledgeBaseComponent_GetKnowledgeBaseByID_Call { + return &MockAgentKnowledgeBaseComponent_GetKnowledgeBaseByID_Call{Call: _e.mock.On("GetKnowledgeBaseByID", ctx, id, userUUID)} +} + +func (_c *MockAgentKnowledgeBaseComponent_GetKnowledgeBaseByID_Call) Run(run func(ctx context.Context, id int64, userUUID string)) *MockAgentKnowledgeBaseComponent_GetKnowledgeBaseByID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(int64), args[2].(string)) + }) + return _c +} + +func (_c *MockAgentKnowledgeBaseComponent_GetKnowledgeBaseByID_Call) Return(_a0 *types.AgentKnowledgeBaseDetail, _a1 error) *MockAgentKnowledgeBaseComponent_GetKnowledgeBaseByID_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAgentKnowledgeBaseComponent_GetKnowledgeBaseByID_Call) RunAndReturn(run func(context.Context, int64, string) (*types.AgentKnowledgeBaseDetail, error)) *MockAgentKnowledgeBaseComponent_GetKnowledgeBaseByID_Call { + _c.Call.Return(run) + return _c +} + +// IsKnowledgeBaseExistsByContentID provides a mock function with given fields: ctx, contentID +func (_m *MockAgentKnowledgeBaseComponent) IsKnowledgeBaseExistsByContentID(ctx context.Context, contentID string) (bool, error) { + ret := _m.Called(ctx, contentID) + + if len(ret) == 0 { + panic("no return value specified for IsKnowledgeBaseExistsByContentID") + } + + var r0 bool + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (bool, error)); ok { + return rf(ctx, contentID) + } + if rf, ok := ret.Get(0).(func(context.Context, string) bool); ok { + r0 = rf(ctx, contentID) + } else { + r0 = ret.Get(0).(bool) + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, contentID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAgentKnowledgeBaseComponent_IsKnowledgeBaseExistsByContentID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsKnowledgeBaseExistsByContentID' +type MockAgentKnowledgeBaseComponent_IsKnowledgeBaseExistsByContentID_Call struct { + *mock.Call +} + +// IsKnowledgeBaseExistsByContentID is a helper method to define mock.On call +// - ctx context.Context +// - contentID string +func (_e *MockAgentKnowledgeBaseComponent_Expecter) IsKnowledgeBaseExistsByContentID(ctx interface{}, contentID interface{}) *MockAgentKnowledgeBaseComponent_IsKnowledgeBaseExistsByContentID_Call { + return &MockAgentKnowledgeBaseComponent_IsKnowledgeBaseExistsByContentID_Call{Call: _e.mock.On("IsKnowledgeBaseExistsByContentID", ctx, contentID)} +} + +func (_c *MockAgentKnowledgeBaseComponent_IsKnowledgeBaseExistsByContentID_Call) Run(run func(ctx context.Context, contentID string)) *MockAgentKnowledgeBaseComponent_IsKnowledgeBaseExistsByContentID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockAgentKnowledgeBaseComponent_IsKnowledgeBaseExistsByContentID_Call) Return(_a0 bool, _a1 error) *MockAgentKnowledgeBaseComponent_IsKnowledgeBaseExistsByContentID_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAgentKnowledgeBaseComponent_IsKnowledgeBaseExistsByContentID_Call) RunAndReturn(run func(context.Context, string) (bool, error)) *MockAgentKnowledgeBaseComponent_IsKnowledgeBaseExistsByContentID_Call { + _c.Call.Return(run) + return _c +} + +// ListKnowledgeBases provides a mock function with given fields: ctx, userUUID, filter, per, page +func (_m *MockAgentKnowledgeBaseComponent) ListKnowledgeBases(ctx context.Context, userUUID string, filter types.AgentKnowledgeBaseFilter, per int, page int) ([]types.AgentKnowledgeBaseListItem, int, error) { + ret := _m.Called(ctx, userUUID, filter, per, page) + + if len(ret) == 0 { + panic("no return value specified for ListKnowledgeBases") + } + + var r0 []types.AgentKnowledgeBaseListItem + var r1 int + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string, types.AgentKnowledgeBaseFilter, int, int) ([]types.AgentKnowledgeBaseListItem, int, error)); ok { + return rf(ctx, userUUID, filter, per, page) + } + if rf, ok := ret.Get(0).(func(context.Context, string, types.AgentKnowledgeBaseFilter, int, int) []types.AgentKnowledgeBaseListItem); ok { + r0 = rf(ctx, userUUID, filter, per, page) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]types.AgentKnowledgeBaseListItem) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, types.AgentKnowledgeBaseFilter, int, int) int); ok { + r1 = rf(ctx, userUUID, filter, per, page) + } else { + r1 = ret.Get(1).(int) + } + + if rf, ok := ret.Get(2).(func(context.Context, string, types.AgentKnowledgeBaseFilter, int, int) error); ok { + r2 = rf(ctx, userUUID, filter, per, page) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockAgentKnowledgeBaseComponent_ListKnowledgeBases_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListKnowledgeBases' +type MockAgentKnowledgeBaseComponent_ListKnowledgeBases_Call struct { + *mock.Call +} + +// ListKnowledgeBases is a helper method to define mock.On call +// - ctx context.Context +// - userUUID string +// - filter types.AgentKnowledgeBaseFilter +// - per int +// - page int +func (_e *MockAgentKnowledgeBaseComponent_Expecter) ListKnowledgeBases(ctx interface{}, userUUID interface{}, filter interface{}, per interface{}, page interface{}) *MockAgentKnowledgeBaseComponent_ListKnowledgeBases_Call { + return &MockAgentKnowledgeBaseComponent_ListKnowledgeBases_Call{Call: _e.mock.On("ListKnowledgeBases", ctx, userUUID, filter, per, page)} +} + +func (_c *MockAgentKnowledgeBaseComponent_ListKnowledgeBases_Call) Run(run func(ctx context.Context, userUUID string, filter types.AgentKnowledgeBaseFilter, per int, page int)) *MockAgentKnowledgeBaseComponent_ListKnowledgeBases_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(types.AgentKnowledgeBaseFilter), args[3].(int), args[4].(int)) + }) + return _c +} + +func (_c *MockAgentKnowledgeBaseComponent_ListKnowledgeBases_Call) Return(_a0 []types.AgentKnowledgeBaseListItem, _a1 int, _a2 error) *MockAgentKnowledgeBaseComponent_ListKnowledgeBases_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockAgentKnowledgeBaseComponent_ListKnowledgeBases_Call) RunAndReturn(run func(context.Context, string, types.AgentKnowledgeBaseFilter, int, int) ([]types.AgentKnowledgeBaseListItem, int, error)) *MockAgentKnowledgeBaseComponent_ListKnowledgeBases_Call { + _c.Call.Return(run) + return _c +} + +// UpdateKnowledgeBase provides a mock function with given fields: ctx, id, userUUID, req +func (_m *MockAgentKnowledgeBaseComponent) UpdateKnowledgeBase(ctx context.Context, id int64, userUUID string, req *types.UpdateAgentKnowledgeBaseRequest) error { + ret := _m.Called(ctx, id, userUUID, req) + + if len(ret) == 0 { + panic("no return value specified for UpdateKnowledgeBase") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, int64, string, *types.UpdateAgentKnowledgeBaseRequest) error); ok { + r0 = rf(ctx, id, userUUID, req) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockAgentKnowledgeBaseComponent_UpdateKnowledgeBase_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateKnowledgeBase' +type MockAgentKnowledgeBaseComponent_UpdateKnowledgeBase_Call struct { + *mock.Call +} + +// UpdateKnowledgeBase is a helper method to define mock.On call +// - ctx context.Context +// - id int64 +// - userUUID string +// - req *types.UpdateAgentKnowledgeBaseRequest +func (_e *MockAgentKnowledgeBaseComponent_Expecter) UpdateKnowledgeBase(ctx interface{}, id interface{}, userUUID interface{}, req interface{}) *MockAgentKnowledgeBaseComponent_UpdateKnowledgeBase_Call { + return &MockAgentKnowledgeBaseComponent_UpdateKnowledgeBase_Call{Call: _e.mock.On("UpdateKnowledgeBase", ctx, id, userUUID, req)} +} + +func (_c *MockAgentKnowledgeBaseComponent_UpdateKnowledgeBase_Call) Run(run func(ctx context.Context, id int64, userUUID string, req *types.UpdateAgentKnowledgeBaseRequest)) *MockAgentKnowledgeBaseComponent_UpdateKnowledgeBase_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(int64), args[2].(string), args[3].(*types.UpdateAgentKnowledgeBaseRequest)) + }) + return _c +} + +func (_c *MockAgentKnowledgeBaseComponent_UpdateKnowledgeBase_Call) Return(_a0 error) *MockAgentKnowledgeBaseComponent_UpdateKnowledgeBase_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAgentKnowledgeBaseComponent_UpdateKnowledgeBase_Call) RunAndReturn(run func(context.Context, int64, string, *types.UpdateAgentKnowledgeBaseRequest) error) *MockAgentKnowledgeBaseComponent_UpdateKnowledgeBase_Call { + _c.Call.Return(run) + return _c +} + +// UpdateKnowledgeBaseByContentID provides a mock function with given fields: ctx, contentID, userUUID, req +func (_m *MockAgentKnowledgeBaseComponent) UpdateKnowledgeBaseByContentID(ctx context.Context, contentID string, userUUID string, req *types.UpdateAgentKnowledgeBaseRequest) error { + ret := _m.Called(ctx, contentID, userUUID, req) + + if len(ret) == 0 { + panic("no return value specified for UpdateKnowledgeBaseByContentID") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, *types.UpdateAgentKnowledgeBaseRequest) error); ok { + r0 = rf(ctx, contentID, userUUID, req) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockAgentKnowledgeBaseComponent_UpdateKnowledgeBaseByContentID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateKnowledgeBaseByContentID' +type MockAgentKnowledgeBaseComponent_UpdateKnowledgeBaseByContentID_Call struct { + *mock.Call +} + +// UpdateKnowledgeBaseByContentID is a helper method to define mock.On call +// - ctx context.Context +// - contentID string +// - userUUID string +// - req *types.UpdateAgentKnowledgeBaseRequest +func (_e *MockAgentKnowledgeBaseComponent_Expecter) UpdateKnowledgeBaseByContentID(ctx interface{}, contentID interface{}, userUUID interface{}, req interface{}) *MockAgentKnowledgeBaseComponent_UpdateKnowledgeBaseByContentID_Call { + return &MockAgentKnowledgeBaseComponent_UpdateKnowledgeBaseByContentID_Call{Call: _e.mock.On("UpdateKnowledgeBaseByContentID", ctx, contentID, userUUID, req)} +} + +func (_c *MockAgentKnowledgeBaseComponent_UpdateKnowledgeBaseByContentID_Call) Run(run func(ctx context.Context, contentID string, userUUID string, req *types.UpdateAgentKnowledgeBaseRequest)) *MockAgentKnowledgeBaseComponent_UpdateKnowledgeBaseByContentID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(*types.UpdateAgentKnowledgeBaseRequest)) + }) + return _c +} + +func (_c *MockAgentKnowledgeBaseComponent_UpdateKnowledgeBaseByContentID_Call) Return(_a0 error) *MockAgentKnowledgeBaseComponent_UpdateKnowledgeBaseByContentID_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAgentKnowledgeBaseComponent_UpdateKnowledgeBaseByContentID_Call) RunAndReturn(run func(context.Context, string, string, *types.UpdateAgentKnowledgeBaseRequest) error) *MockAgentKnowledgeBaseComponent_UpdateKnowledgeBaseByContentID_Call { + _c.Call.Return(run) + return _c +} + +// NewMockAgentKnowledgeBaseComponent creates a new instance of MockAgentKnowledgeBaseComponent. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockAgentKnowledgeBaseComponent(t interface { + mock.TestingT + Cleanup(func()) +}) *MockAgentKnowledgeBaseComponent { + mock := &MockAgentKnowledgeBaseComponent{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/_mocks/opencsg.com/csghub-server/component/mock_AgentMCPServerComponent.go b/_mocks/opencsg.com/csghub-server/component/mock_AgentMCPServerComponent.go new file mode 100644 index 000000000..106e2dc32 --- /dev/null +++ b/_mocks/opencsg.com/csghub-server/component/mock_AgentMCPServerComponent.go @@ -0,0 +1,310 @@ +// Code generated by mockery v2.53.5. DO NOT EDIT. + +package component + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + types "opencsg.com/csghub-server/common/types" +) + +// MockAgentMCPServerComponent is an autogenerated mock type for the AgentMCPServerComponent type +type MockAgentMCPServerComponent struct { + mock.Mock +} + +type MockAgentMCPServerComponent_Expecter struct { + mock *mock.Mock +} + +func (_m *MockAgentMCPServerComponent) EXPECT() *MockAgentMCPServerComponent_Expecter { + return &MockAgentMCPServerComponent_Expecter{mock: &_m.Mock} +} + +// CreateMCPServer provides a mock function with given fields: ctx, server +func (_m *MockAgentMCPServerComponent) CreateMCPServer(ctx context.Context, server *types.AgentMCPServer) error { + ret := _m.Called(ctx, server) + + if len(ret) == 0 { + panic("no return value specified for CreateMCPServer") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, *types.AgentMCPServer) error); ok { + r0 = rf(ctx, server) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockAgentMCPServerComponent_CreateMCPServer_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateMCPServer' +type MockAgentMCPServerComponent_CreateMCPServer_Call struct { + *mock.Call +} + +// CreateMCPServer is a helper method to define mock.On call +// - ctx context.Context +// - server *types.AgentMCPServer +func (_e *MockAgentMCPServerComponent_Expecter) CreateMCPServer(ctx interface{}, server interface{}) *MockAgentMCPServerComponent_CreateMCPServer_Call { + return &MockAgentMCPServerComponent_CreateMCPServer_Call{Call: _e.mock.On("CreateMCPServer", ctx, server)} +} + +func (_c *MockAgentMCPServerComponent_CreateMCPServer_Call) Run(run func(ctx context.Context, server *types.AgentMCPServer)) *MockAgentMCPServerComponent_CreateMCPServer_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*types.AgentMCPServer)) + }) + return _c +} + +func (_c *MockAgentMCPServerComponent_CreateMCPServer_Call) Return(_a0 error) *MockAgentMCPServerComponent_CreateMCPServer_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAgentMCPServerComponent_CreateMCPServer_Call) RunAndReturn(run func(context.Context, *types.AgentMCPServer) error) *MockAgentMCPServerComponent_CreateMCPServer_Call { + _c.Call.Return(run) + return _c +} + +// DeleteMCPServer provides a mock function with given fields: ctx, id, userUUID +func (_m *MockAgentMCPServerComponent) DeleteMCPServer(ctx context.Context, id string, userUUID string) error { + ret := _m.Called(ctx, id, userUUID) + + if len(ret) == 0 { + panic("no return value specified for DeleteMCPServer") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok { + r0 = rf(ctx, id, userUUID) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockAgentMCPServerComponent_DeleteMCPServer_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteMCPServer' +type MockAgentMCPServerComponent_DeleteMCPServer_Call struct { + *mock.Call +} + +// DeleteMCPServer is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - userUUID string +func (_e *MockAgentMCPServerComponent_Expecter) DeleteMCPServer(ctx interface{}, id interface{}, userUUID interface{}) *MockAgentMCPServerComponent_DeleteMCPServer_Call { + return &MockAgentMCPServerComponent_DeleteMCPServer_Call{Call: _e.mock.On("DeleteMCPServer", ctx, id, userUUID)} +} + +func (_c *MockAgentMCPServerComponent_DeleteMCPServer_Call) Run(run func(ctx context.Context, id string, userUUID string)) *MockAgentMCPServerComponent_DeleteMCPServer_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string)) + }) + return _c +} + +func (_c *MockAgentMCPServerComponent_DeleteMCPServer_Call) Return(_a0 error) *MockAgentMCPServerComponent_DeleteMCPServer_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAgentMCPServerComponent_DeleteMCPServer_Call) RunAndReturn(run func(context.Context, string, string) error) *MockAgentMCPServerComponent_DeleteMCPServer_Call { + _c.Call.Return(run) + return _c +} + +// GetMCPServerByID provides a mock function with given fields: ctx, id, userUUID +func (_m *MockAgentMCPServerComponent) GetMCPServerByID(ctx context.Context, id string, userUUID string) (*types.AgentMCPServerDetail, error) { + ret := _m.Called(ctx, id, userUUID) + + if len(ret) == 0 { + panic("no return value specified for GetMCPServerByID") + } + + var r0 *types.AgentMCPServerDetail + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string) (*types.AgentMCPServerDetail, error)); ok { + return rf(ctx, id, userUUID) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string) *types.AgentMCPServerDetail); ok { + r0 = rf(ctx, id, userUUID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.AgentMCPServerDetail) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string) error); ok { + r1 = rf(ctx, id, userUUID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAgentMCPServerComponent_GetMCPServerByID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetMCPServerByID' +type MockAgentMCPServerComponent_GetMCPServerByID_Call struct { + *mock.Call +} + +// GetMCPServerByID is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - userUUID string +func (_e *MockAgentMCPServerComponent_Expecter) GetMCPServerByID(ctx interface{}, id interface{}, userUUID interface{}) *MockAgentMCPServerComponent_GetMCPServerByID_Call { + return &MockAgentMCPServerComponent_GetMCPServerByID_Call{Call: _e.mock.On("GetMCPServerByID", ctx, id, userUUID)} +} + +func (_c *MockAgentMCPServerComponent_GetMCPServerByID_Call) Run(run func(ctx context.Context, id string, userUUID string)) *MockAgentMCPServerComponent_GetMCPServerByID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string)) + }) + return _c +} + +func (_c *MockAgentMCPServerComponent_GetMCPServerByID_Call) Return(_a0 *types.AgentMCPServerDetail, _a1 error) *MockAgentMCPServerComponent_GetMCPServerByID_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAgentMCPServerComponent_GetMCPServerByID_Call) RunAndReturn(run func(context.Context, string, string) (*types.AgentMCPServerDetail, error)) *MockAgentMCPServerComponent_GetMCPServerByID_Call { + _c.Call.Return(run) + return _c +} + +// ListMCPServers provides a mock function with given fields: ctx, userUUID, filter, per, page +func (_m *MockAgentMCPServerComponent) ListMCPServers(ctx context.Context, userUUID string, filter types.AgentMCPServerFilter, per int, page int) ([]types.AgentMCPServerListItem, int, error) { + ret := _m.Called(ctx, userUUID, filter, per, page) + + if len(ret) == 0 { + panic("no return value specified for ListMCPServers") + } + + var r0 []types.AgentMCPServerListItem + var r1 int + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string, types.AgentMCPServerFilter, int, int) ([]types.AgentMCPServerListItem, int, error)); ok { + return rf(ctx, userUUID, filter, per, page) + } + if rf, ok := ret.Get(0).(func(context.Context, string, types.AgentMCPServerFilter, int, int) []types.AgentMCPServerListItem); ok { + r0 = rf(ctx, userUUID, filter, per, page) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]types.AgentMCPServerListItem) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, types.AgentMCPServerFilter, int, int) int); ok { + r1 = rf(ctx, userUUID, filter, per, page) + } else { + r1 = ret.Get(1).(int) + } + + if rf, ok := ret.Get(2).(func(context.Context, string, types.AgentMCPServerFilter, int, int) error); ok { + r2 = rf(ctx, userUUID, filter, per, page) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockAgentMCPServerComponent_ListMCPServers_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListMCPServers' +type MockAgentMCPServerComponent_ListMCPServers_Call struct { + *mock.Call +} + +// ListMCPServers is a helper method to define mock.On call +// - ctx context.Context +// - userUUID string +// - filter types.AgentMCPServerFilter +// - per int +// - page int +func (_e *MockAgentMCPServerComponent_Expecter) ListMCPServers(ctx interface{}, userUUID interface{}, filter interface{}, per interface{}, page interface{}) *MockAgentMCPServerComponent_ListMCPServers_Call { + return &MockAgentMCPServerComponent_ListMCPServers_Call{Call: _e.mock.On("ListMCPServers", ctx, userUUID, filter, per, page)} +} + +func (_c *MockAgentMCPServerComponent_ListMCPServers_Call) Run(run func(ctx context.Context, userUUID string, filter types.AgentMCPServerFilter, per int, page int)) *MockAgentMCPServerComponent_ListMCPServers_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(types.AgentMCPServerFilter), args[3].(int), args[4].(int)) + }) + return _c +} + +func (_c *MockAgentMCPServerComponent_ListMCPServers_Call) Return(_a0 []types.AgentMCPServerListItem, _a1 int, _a2 error) *MockAgentMCPServerComponent_ListMCPServers_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockAgentMCPServerComponent_ListMCPServers_Call) RunAndReturn(run func(context.Context, string, types.AgentMCPServerFilter, int, int) ([]types.AgentMCPServerListItem, int, error)) *MockAgentMCPServerComponent_ListMCPServers_Call { + _c.Call.Return(run) + return _c +} + +// UpdateMCPServer provides a mock function with given fields: ctx, id, userUUID, req +func (_m *MockAgentMCPServerComponent) UpdateMCPServer(ctx context.Context, id string, userUUID string, req *types.UpdateAgentMCPServerRequest) error { + ret := _m.Called(ctx, id, userUUID, req) + + if len(ret) == 0 { + panic("no return value specified for UpdateMCPServer") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, *types.UpdateAgentMCPServerRequest) error); ok { + r0 = rf(ctx, id, userUUID, req) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockAgentMCPServerComponent_UpdateMCPServer_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateMCPServer' +type MockAgentMCPServerComponent_UpdateMCPServer_Call struct { + *mock.Call +} + +// UpdateMCPServer is a helper method to define mock.On call +// - ctx context.Context +// - id string +// - userUUID string +// - req *types.UpdateAgentMCPServerRequest +func (_e *MockAgentMCPServerComponent_Expecter) UpdateMCPServer(ctx interface{}, id interface{}, userUUID interface{}, req interface{}) *MockAgentMCPServerComponent_UpdateMCPServer_Call { + return &MockAgentMCPServerComponent_UpdateMCPServer_Call{Call: _e.mock.On("UpdateMCPServer", ctx, id, userUUID, req)} +} + +func (_c *MockAgentMCPServerComponent_UpdateMCPServer_Call) Run(run func(ctx context.Context, id string, userUUID string, req *types.UpdateAgentMCPServerRequest)) *MockAgentMCPServerComponent_UpdateMCPServer_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(*types.UpdateAgentMCPServerRequest)) + }) + return _c +} + +func (_c *MockAgentMCPServerComponent_UpdateMCPServer_Call) Return(_a0 error) *MockAgentMCPServerComponent_UpdateMCPServer_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAgentMCPServerComponent_UpdateMCPServer_Call) RunAndReturn(run func(context.Context, string, string, *types.UpdateAgentMCPServerRequest) error) *MockAgentMCPServerComponent_UpdateMCPServer_Call { + _c.Call.Return(run) + return _c +} + +// NewMockAgentMCPServerComponent creates a new instance of MockAgentMCPServerComponent. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockAgentMCPServerComponent(t interface { + mock.TestingT + Cleanup(func()) +}) *MockAgentMCPServerComponent { + mock := &MockAgentMCPServerComponent{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/_mocks/opencsg.com/csghub-server/component/mock_AgentTaskComponent.go b/_mocks/opencsg.com/csghub-server/component/mock_AgentTaskComponent.go new file mode 100644 index 000000000..e278113f3 --- /dev/null +++ b/_mocks/opencsg.com/csghub-server/component/mock_AgentTaskComponent.go @@ -0,0 +1,213 @@ +// Code generated by mockery v2.53.5. DO NOT EDIT. + +package component + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + types "opencsg.com/csghub-server/common/types" +) + +// MockAgentTaskComponent is an autogenerated mock type for the AgentTaskComponent type +type MockAgentTaskComponent struct { + mock.Mock +} + +type MockAgentTaskComponent_Expecter struct { + mock *mock.Mock +} + +func (_m *MockAgentTaskComponent) EXPECT() *MockAgentTaskComponent_Expecter { + return &MockAgentTaskComponent_Expecter{mock: &_m.Mock} +} + +// CreateTaskIfInstanceExists provides a mock function with given fields: ctx, req +func (_m *MockAgentTaskComponent) CreateTaskIfInstanceExists(ctx context.Context, req *types.AgentInstanceTaskReq) error { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for CreateTaskIfInstanceExists") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, *types.AgentInstanceTaskReq) error); ok { + r0 = rf(ctx, req) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockAgentTaskComponent_CreateTaskIfInstanceExists_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateTaskIfInstanceExists' +type MockAgentTaskComponent_CreateTaskIfInstanceExists_Call struct { + *mock.Call +} + +// CreateTaskIfInstanceExists is a helper method to define mock.On call +// - ctx context.Context +// - req *types.AgentInstanceTaskReq +func (_e *MockAgentTaskComponent_Expecter) CreateTaskIfInstanceExists(ctx interface{}, req interface{}) *MockAgentTaskComponent_CreateTaskIfInstanceExists_Call { + return &MockAgentTaskComponent_CreateTaskIfInstanceExists_Call{Call: _e.mock.On("CreateTaskIfInstanceExists", ctx, req)} +} + +func (_c *MockAgentTaskComponent_CreateTaskIfInstanceExists_Call) Run(run func(ctx context.Context, req *types.AgentInstanceTaskReq)) *MockAgentTaskComponent_CreateTaskIfInstanceExists_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*types.AgentInstanceTaskReq)) + }) + return _c +} + +func (_c *MockAgentTaskComponent_CreateTaskIfInstanceExists_Call) Return(_a0 error) *MockAgentTaskComponent_CreateTaskIfInstanceExists_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAgentTaskComponent_CreateTaskIfInstanceExists_Call) RunAndReturn(run func(context.Context, *types.AgentInstanceTaskReq) error) *MockAgentTaskComponent_CreateTaskIfInstanceExists_Call { + _c.Call.Return(run) + return _c +} + +// GetTaskDetail provides a mock function with given fields: ctx, userUUID, id +func (_m *MockAgentTaskComponent) GetTaskDetail(ctx context.Context, userUUID string, id int64) (*types.AgentTaskDetail, error) { + ret := _m.Called(ctx, userUUID, id) + + if len(ret) == 0 { + panic("no return value specified for GetTaskDetail") + } + + var r0 *types.AgentTaskDetail + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, int64) (*types.AgentTaskDetail, error)); ok { + return rf(ctx, userUUID, id) + } + if rf, ok := ret.Get(0).(func(context.Context, string, int64) *types.AgentTaskDetail); ok { + r0 = rf(ctx, userUUID, id) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.AgentTaskDetail) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, int64) error); ok { + r1 = rf(ctx, userUUID, id) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAgentTaskComponent_GetTaskDetail_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTaskDetail' +type MockAgentTaskComponent_GetTaskDetail_Call struct { + *mock.Call +} + +// GetTaskDetail is a helper method to define mock.On call +// - ctx context.Context +// - userUUID string +// - id int64 +func (_e *MockAgentTaskComponent_Expecter) GetTaskDetail(ctx interface{}, userUUID interface{}, id interface{}) *MockAgentTaskComponent_GetTaskDetail_Call { + return &MockAgentTaskComponent_GetTaskDetail_Call{Call: _e.mock.On("GetTaskDetail", ctx, userUUID, id)} +} + +func (_c *MockAgentTaskComponent_GetTaskDetail_Call) Run(run func(ctx context.Context, userUUID string, id int64)) *MockAgentTaskComponent_GetTaskDetail_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(int64)) + }) + return _c +} + +func (_c *MockAgentTaskComponent_GetTaskDetail_Call) Return(_a0 *types.AgentTaskDetail, _a1 error) *MockAgentTaskComponent_GetTaskDetail_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAgentTaskComponent_GetTaskDetail_Call) RunAndReturn(run func(context.Context, string, int64) (*types.AgentTaskDetail, error)) *MockAgentTaskComponent_GetTaskDetail_Call { + _c.Call.Return(run) + return _c +} + +// ListTasks provides a mock function with given fields: ctx, userUUID, filter, per, page +func (_m *MockAgentTaskComponent) ListTasks(ctx context.Context, userUUID string, filter types.AgentTaskFilter, per int, page int) ([]types.AgentTaskListItem, int, error) { + ret := _m.Called(ctx, userUUID, filter, per, page) + + if len(ret) == 0 { + panic("no return value specified for ListTasks") + } + + var r0 []types.AgentTaskListItem + var r1 int + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string, types.AgentTaskFilter, int, int) ([]types.AgentTaskListItem, int, error)); ok { + return rf(ctx, userUUID, filter, per, page) + } + if rf, ok := ret.Get(0).(func(context.Context, string, types.AgentTaskFilter, int, int) []types.AgentTaskListItem); ok { + r0 = rf(ctx, userUUID, filter, per, page) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]types.AgentTaskListItem) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, types.AgentTaskFilter, int, int) int); ok { + r1 = rf(ctx, userUUID, filter, per, page) + } else { + r1 = ret.Get(1).(int) + } + + if rf, ok := ret.Get(2).(func(context.Context, string, types.AgentTaskFilter, int, int) error); ok { + r2 = rf(ctx, userUUID, filter, per, page) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockAgentTaskComponent_ListTasks_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListTasks' +type MockAgentTaskComponent_ListTasks_Call struct { + *mock.Call +} + +// ListTasks is a helper method to define mock.On call +// - ctx context.Context +// - userUUID string +// - filter types.AgentTaskFilter +// - per int +// - page int +func (_e *MockAgentTaskComponent_Expecter) ListTasks(ctx interface{}, userUUID interface{}, filter interface{}, per interface{}, page interface{}) *MockAgentTaskComponent_ListTasks_Call { + return &MockAgentTaskComponent_ListTasks_Call{Call: _e.mock.On("ListTasks", ctx, userUUID, filter, per, page)} +} + +func (_c *MockAgentTaskComponent_ListTasks_Call) Run(run func(ctx context.Context, userUUID string, filter types.AgentTaskFilter, per int, page int)) *MockAgentTaskComponent_ListTasks_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(types.AgentTaskFilter), args[3].(int), args[4].(int)) + }) + return _c +} + +func (_c *MockAgentTaskComponent_ListTasks_Call) Return(_a0 []types.AgentTaskListItem, _a1 int, _a2 error) *MockAgentTaskComponent_ListTasks_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockAgentTaskComponent_ListTasks_Call) RunAndReturn(run func(context.Context, string, types.AgentTaskFilter, int, int) ([]types.AgentTaskListItem, int, error)) *MockAgentTaskComponent_ListTasks_Call { + _c.Call.Return(run) + return _c +} + +// NewMockAgentTaskComponent creates a new instance of MockAgentTaskComponent. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockAgentTaskComponent(t interface { + mock.TestingT + Cleanup(func()) +}) *MockAgentTaskComponent { + mock := &MockAgentTaskComponent{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/_mocks/opencsg.com/csghub-server/component/mock_AgentTemplateComponent.go b/_mocks/opencsg.com/csghub-server/component/mock_AgentTemplateComponent.go new file mode 100644 index 000000000..ce740dd1f --- /dev/null +++ b/_mocks/opencsg.com/csghub-server/component/mock_AgentTemplateComponent.go @@ -0,0 +1,308 @@ +// Code generated by mockery v2.53.5. DO NOT EDIT. + +package component + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + types "opencsg.com/csghub-server/common/types" +) + +// MockAgentTemplateComponent is an autogenerated mock type for the AgentTemplateComponent type +type MockAgentTemplateComponent struct { + mock.Mock +} + +type MockAgentTemplateComponent_Expecter struct { + mock *mock.Mock +} + +func (_m *MockAgentTemplateComponent) EXPECT() *MockAgentTemplateComponent_Expecter { + return &MockAgentTemplateComponent_Expecter{mock: &_m.Mock} +} + +// CreateTemplate provides a mock function with given fields: ctx, template +func (_m *MockAgentTemplateComponent) CreateTemplate(ctx context.Context, template *types.AgentTemplate) error { + ret := _m.Called(ctx, template) + + if len(ret) == 0 { + panic("no return value specified for CreateTemplate") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, *types.AgentTemplate) error); ok { + r0 = rf(ctx, template) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockAgentTemplateComponent_CreateTemplate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateTemplate' +type MockAgentTemplateComponent_CreateTemplate_Call struct { + *mock.Call +} + +// CreateTemplate is a helper method to define mock.On call +// - ctx context.Context +// - template *types.AgentTemplate +func (_e *MockAgentTemplateComponent_Expecter) CreateTemplate(ctx interface{}, template interface{}) *MockAgentTemplateComponent_CreateTemplate_Call { + return &MockAgentTemplateComponent_CreateTemplate_Call{Call: _e.mock.On("CreateTemplate", ctx, template)} +} + +func (_c *MockAgentTemplateComponent_CreateTemplate_Call) Run(run func(ctx context.Context, template *types.AgentTemplate)) *MockAgentTemplateComponent_CreateTemplate_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*types.AgentTemplate)) + }) + return _c +} + +func (_c *MockAgentTemplateComponent_CreateTemplate_Call) Return(_a0 error) *MockAgentTemplateComponent_CreateTemplate_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAgentTemplateComponent_CreateTemplate_Call) RunAndReturn(run func(context.Context, *types.AgentTemplate) error) *MockAgentTemplateComponent_CreateTemplate_Call { + _c.Call.Return(run) + return _c +} + +// DeleteTemplate provides a mock function with given fields: ctx, id, userUUID +func (_m *MockAgentTemplateComponent) DeleteTemplate(ctx context.Context, id int64, userUUID string) error { + ret := _m.Called(ctx, id, userUUID) + + if len(ret) == 0 { + panic("no return value specified for DeleteTemplate") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, int64, string) error); ok { + r0 = rf(ctx, id, userUUID) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockAgentTemplateComponent_DeleteTemplate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteTemplate' +type MockAgentTemplateComponent_DeleteTemplate_Call struct { + *mock.Call +} + +// DeleteTemplate is a helper method to define mock.On call +// - ctx context.Context +// - id int64 +// - userUUID string +func (_e *MockAgentTemplateComponent_Expecter) DeleteTemplate(ctx interface{}, id interface{}, userUUID interface{}) *MockAgentTemplateComponent_DeleteTemplate_Call { + return &MockAgentTemplateComponent_DeleteTemplate_Call{Call: _e.mock.On("DeleteTemplate", ctx, id, userUUID)} +} + +func (_c *MockAgentTemplateComponent_DeleteTemplate_Call) Run(run func(ctx context.Context, id int64, userUUID string)) *MockAgentTemplateComponent_DeleteTemplate_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(int64), args[2].(string)) + }) + return _c +} + +func (_c *MockAgentTemplateComponent_DeleteTemplate_Call) Return(_a0 error) *MockAgentTemplateComponent_DeleteTemplate_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAgentTemplateComponent_DeleteTemplate_Call) RunAndReturn(run func(context.Context, int64, string) error) *MockAgentTemplateComponent_DeleteTemplate_Call { + _c.Call.Return(run) + return _c +} + +// GetTemplateByID provides a mock function with given fields: ctx, id, userUUID +func (_m *MockAgentTemplateComponent) GetTemplateByID(ctx context.Context, id int64, userUUID string) (*types.AgentTemplate, error) { + ret := _m.Called(ctx, id, userUUID) + + if len(ret) == 0 { + panic("no return value specified for GetTemplateByID") + } + + var r0 *types.AgentTemplate + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, int64, string) (*types.AgentTemplate, error)); ok { + return rf(ctx, id, userUUID) + } + if rf, ok := ret.Get(0).(func(context.Context, int64, string) *types.AgentTemplate); ok { + r0 = rf(ctx, id, userUUID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.AgentTemplate) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, int64, string) error); ok { + r1 = rf(ctx, id, userUUID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockAgentTemplateComponent_GetTemplateByID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTemplateByID' +type MockAgentTemplateComponent_GetTemplateByID_Call struct { + *mock.Call +} + +// GetTemplateByID is a helper method to define mock.On call +// - ctx context.Context +// - id int64 +// - userUUID string +func (_e *MockAgentTemplateComponent_Expecter) GetTemplateByID(ctx interface{}, id interface{}, userUUID interface{}) *MockAgentTemplateComponent_GetTemplateByID_Call { + return &MockAgentTemplateComponent_GetTemplateByID_Call{Call: _e.mock.On("GetTemplateByID", ctx, id, userUUID)} +} + +func (_c *MockAgentTemplateComponent_GetTemplateByID_Call) Run(run func(ctx context.Context, id int64, userUUID string)) *MockAgentTemplateComponent_GetTemplateByID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(int64), args[2].(string)) + }) + return _c +} + +func (_c *MockAgentTemplateComponent_GetTemplateByID_Call) Return(_a0 *types.AgentTemplate, _a1 error) *MockAgentTemplateComponent_GetTemplateByID_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockAgentTemplateComponent_GetTemplateByID_Call) RunAndReturn(run func(context.Context, int64, string) (*types.AgentTemplate, error)) *MockAgentTemplateComponent_GetTemplateByID_Call { + _c.Call.Return(run) + return _c +} + +// ListTemplatesByUserUUID provides a mock function with given fields: ctx, userUUID, filter, per, page +func (_m *MockAgentTemplateComponent) ListTemplatesByUserUUID(ctx context.Context, userUUID string, filter types.AgentTemplateFilter, per int, page int) ([]types.AgentTemplate, int, error) { + ret := _m.Called(ctx, userUUID, filter, per, page) + + if len(ret) == 0 { + panic("no return value specified for ListTemplatesByUserUUID") + } + + var r0 []types.AgentTemplate + var r1 int + var r2 error + if rf, ok := ret.Get(0).(func(context.Context, string, types.AgentTemplateFilter, int, int) ([]types.AgentTemplate, int, error)); ok { + return rf(ctx, userUUID, filter, per, page) + } + if rf, ok := ret.Get(0).(func(context.Context, string, types.AgentTemplateFilter, int, int) []types.AgentTemplate); ok { + r0 = rf(ctx, userUUID, filter, per, page) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]types.AgentTemplate) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, types.AgentTemplateFilter, int, int) int); ok { + r1 = rf(ctx, userUUID, filter, per, page) + } else { + r1 = ret.Get(1).(int) + } + + if rf, ok := ret.Get(2).(func(context.Context, string, types.AgentTemplateFilter, int, int) error); ok { + r2 = rf(ctx, userUUID, filter, per, page) + } else { + r2 = ret.Error(2) + } + + return r0, r1, r2 +} + +// MockAgentTemplateComponent_ListTemplatesByUserUUID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListTemplatesByUserUUID' +type MockAgentTemplateComponent_ListTemplatesByUserUUID_Call struct { + *mock.Call +} + +// ListTemplatesByUserUUID is a helper method to define mock.On call +// - ctx context.Context +// - userUUID string +// - filter types.AgentTemplateFilter +// - per int +// - page int +func (_e *MockAgentTemplateComponent_Expecter) ListTemplatesByUserUUID(ctx interface{}, userUUID interface{}, filter interface{}, per interface{}, page interface{}) *MockAgentTemplateComponent_ListTemplatesByUserUUID_Call { + return &MockAgentTemplateComponent_ListTemplatesByUserUUID_Call{Call: _e.mock.On("ListTemplatesByUserUUID", ctx, userUUID, filter, per, page)} +} + +func (_c *MockAgentTemplateComponent_ListTemplatesByUserUUID_Call) Run(run func(ctx context.Context, userUUID string, filter types.AgentTemplateFilter, per int, page int)) *MockAgentTemplateComponent_ListTemplatesByUserUUID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(types.AgentTemplateFilter), args[3].(int), args[4].(int)) + }) + return _c +} + +func (_c *MockAgentTemplateComponent_ListTemplatesByUserUUID_Call) Return(_a0 []types.AgentTemplate, _a1 int, _a2 error) *MockAgentTemplateComponent_ListTemplatesByUserUUID_Call { + _c.Call.Return(_a0, _a1, _a2) + return _c +} + +func (_c *MockAgentTemplateComponent_ListTemplatesByUserUUID_Call) RunAndReturn(run func(context.Context, string, types.AgentTemplateFilter, int, int) ([]types.AgentTemplate, int, error)) *MockAgentTemplateComponent_ListTemplatesByUserUUID_Call { + _c.Call.Return(run) + return _c +} + +// UpdateTemplate provides a mock function with given fields: ctx, template +func (_m *MockAgentTemplateComponent) UpdateTemplate(ctx context.Context, template *types.AgentTemplate) error { + ret := _m.Called(ctx, template) + + if len(ret) == 0 { + panic("no return value specified for UpdateTemplate") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, *types.AgentTemplate) error); ok { + r0 = rf(ctx, template) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockAgentTemplateComponent_UpdateTemplate_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateTemplate' +type MockAgentTemplateComponent_UpdateTemplate_Call struct { + *mock.Call +} + +// UpdateTemplate is a helper method to define mock.On call +// - ctx context.Context +// - template *types.AgentTemplate +func (_e *MockAgentTemplateComponent_Expecter) UpdateTemplate(ctx interface{}, template interface{}) *MockAgentTemplateComponent_UpdateTemplate_Call { + return &MockAgentTemplateComponent_UpdateTemplate_Call{Call: _e.mock.On("UpdateTemplate", ctx, template)} +} + +func (_c *MockAgentTemplateComponent_UpdateTemplate_Call) Run(run func(ctx context.Context, template *types.AgentTemplate)) *MockAgentTemplateComponent_UpdateTemplate_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*types.AgentTemplate)) + }) + return _c +} + +func (_c *MockAgentTemplateComponent_UpdateTemplate_Call) Return(_a0 error) *MockAgentTemplateComponent_UpdateTemplate_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockAgentTemplateComponent_UpdateTemplate_Call) RunAndReturn(run func(context.Context, *types.AgentTemplate) error) *MockAgentTemplateComponent_UpdateTemplate_Call { + _c.Call.Return(run) + return _c +} + +// NewMockAgentTemplateComponent creates a new instance of MockAgentTemplateComponent. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockAgentTemplateComponent(t interface { + mock.TestingT + Cleanup(func()) +}) *MockAgentTemplateComponent { + mock := &MockAgentTemplateComponent{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/_mocks/opencsg.com/csghub-server/component/mock_EventComponent.go b/_mocks/opencsg.com/csghub-server/component/mock_EventComponent.go new file mode 100644 index 000000000..6408201f0 --- /dev/null +++ b/_mocks/opencsg.com/csghub-server/component/mock_EventComponent.go @@ -0,0 +1,84 @@ +// Code generated by mockery v2.53.5. DO NOT EDIT. + +package component + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + types "opencsg.com/csghub-server/common/types" +) + +// MockEventComponent is an autogenerated mock type for the EventComponent type +type MockEventComponent struct { + mock.Mock +} + +type MockEventComponent_Expecter struct { + mock *mock.Mock +} + +func (_m *MockEventComponent) EXPECT() *MockEventComponent_Expecter { + return &MockEventComponent_Expecter{mock: &_m.Mock} +} + +// NewEvents provides a mock function with given fields: ctx, events +func (_m *MockEventComponent) NewEvents(ctx context.Context, events []types.Event) error { + ret := _m.Called(ctx, events) + + if len(ret) == 0 { + panic("no return value specified for NewEvents") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, []types.Event) error); ok { + r0 = rf(ctx, events) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockEventComponent_NewEvents_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'NewEvents' +type MockEventComponent_NewEvents_Call struct { + *mock.Call +} + +// NewEvents is a helper method to define mock.On call +// - ctx context.Context +// - events []types.Event +func (_e *MockEventComponent_Expecter) NewEvents(ctx interface{}, events interface{}) *MockEventComponent_NewEvents_Call { + return &MockEventComponent_NewEvents_Call{Call: _e.mock.On("NewEvents", ctx, events)} +} + +func (_c *MockEventComponent_NewEvents_Call) Run(run func(ctx context.Context, events []types.Event)) *MockEventComponent_NewEvents_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].([]types.Event)) + }) + return _c +} + +func (_c *MockEventComponent_NewEvents_Call) Return(_a0 error) *MockEventComponent_NewEvents_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockEventComponent_NewEvents_Call) RunAndReturn(run func(context.Context, []types.Event) error) *MockEventComponent_NewEvents_Call { + _c.Call.Return(run) + return _c +} + +// NewMockEventComponent creates a new instance of MockEventComponent. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockEventComponent(t interface { + mock.TestingT + Cleanup(func()) +}) *MockEventComponent { + mock := &MockEventComponent{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/_mocks/opencsg.com/csghub-server/component/mock_HFDatasetComponent.go b/_mocks/opencsg.com/csghub-server/component/mock_HFDatasetComponent.go new file mode 100644 index 000000000..0fd6440c2 --- /dev/null +++ b/_mocks/opencsg.com/csghub-server/component/mock_HFDatasetComponent.go @@ -0,0 +1,155 @@ +// Code generated by mockery v2.53.5. DO NOT EDIT. + +package component + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + types "opencsg.com/csghub-server/common/types" +) + +// MockHFDatasetComponent is an autogenerated mock type for the HFDatasetComponent type +type MockHFDatasetComponent struct { + mock.Mock +} + +type MockHFDatasetComponent_Expecter struct { + mock *mock.Mock +} + +func (_m *MockHFDatasetComponent) EXPECT() *MockHFDatasetComponent_Expecter { + return &MockHFDatasetComponent_Expecter{mock: &_m.Mock} +} + +// GetDatasetTree provides a mock function with given fields: ctx, req +func (_m *MockHFDatasetComponent) GetDatasetTree(ctx context.Context, req types.PathReq) ([]types.HFDSPathInfo, error) { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for GetDatasetTree") + } + + var r0 []types.HFDSPathInfo + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, types.PathReq) ([]types.HFDSPathInfo, error)); ok { + return rf(ctx, req) + } + if rf, ok := ret.Get(0).(func(context.Context, types.PathReq) []types.HFDSPathInfo); ok { + r0 = rf(ctx, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]types.HFDSPathInfo) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, types.PathReq) error); ok { + r1 = rf(ctx, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockHFDatasetComponent_GetDatasetTree_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetDatasetTree' +type MockHFDatasetComponent_GetDatasetTree_Call struct { + *mock.Call +} + +// GetDatasetTree is a helper method to define mock.On call +// - ctx context.Context +// - req types.PathReq +func (_e *MockHFDatasetComponent_Expecter) GetDatasetTree(ctx interface{}, req interface{}) *MockHFDatasetComponent_GetDatasetTree_Call { + return &MockHFDatasetComponent_GetDatasetTree_Call{Call: _e.mock.On("GetDatasetTree", ctx, req)} +} + +func (_c *MockHFDatasetComponent_GetDatasetTree_Call) Run(run func(ctx context.Context, req types.PathReq)) *MockHFDatasetComponent_GetDatasetTree_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(types.PathReq)) + }) + return _c +} + +func (_c *MockHFDatasetComponent_GetDatasetTree_Call) Return(_a0 []types.HFDSPathInfo, _a1 error) *MockHFDatasetComponent_GetDatasetTree_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockHFDatasetComponent_GetDatasetTree_Call) RunAndReturn(run func(context.Context, types.PathReq) ([]types.HFDSPathInfo, error)) *MockHFDatasetComponent_GetDatasetTree_Call { + _c.Call.Return(run) + return _c +} + +// GetPathsInfo provides a mock function with given fields: ctx, req +func (_m *MockHFDatasetComponent) GetPathsInfo(ctx context.Context, req types.PathReq) ([]types.HFDSPathInfo, error) { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for GetPathsInfo") + } + + var r0 []types.HFDSPathInfo + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, types.PathReq) ([]types.HFDSPathInfo, error)); ok { + return rf(ctx, req) + } + if rf, ok := ret.Get(0).(func(context.Context, types.PathReq) []types.HFDSPathInfo); ok { + r0 = rf(ctx, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]types.HFDSPathInfo) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, types.PathReq) error); ok { + r1 = rf(ctx, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockHFDatasetComponent_GetPathsInfo_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetPathsInfo' +type MockHFDatasetComponent_GetPathsInfo_Call struct { + *mock.Call +} + +// GetPathsInfo is a helper method to define mock.On call +// - ctx context.Context +// - req types.PathReq +func (_e *MockHFDatasetComponent_Expecter) GetPathsInfo(ctx interface{}, req interface{}) *MockHFDatasetComponent_GetPathsInfo_Call { + return &MockHFDatasetComponent_GetPathsInfo_Call{Call: _e.mock.On("GetPathsInfo", ctx, req)} +} + +func (_c *MockHFDatasetComponent_GetPathsInfo_Call) Run(run func(ctx context.Context, req types.PathReq)) *MockHFDatasetComponent_GetPathsInfo_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(types.PathReq)) + }) + return _c +} + +func (_c *MockHFDatasetComponent_GetPathsInfo_Call) Return(_a0 []types.HFDSPathInfo, _a1 error) *MockHFDatasetComponent_GetPathsInfo_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockHFDatasetComponent_GetPathsInfo_Call) RunAndReturn(run func(context.Context, types.PathReq) ([]types.HFDSPathInfo, error)) *MockHFDatasetComponent_GetPathsInfo_Call { + _c.Call.Return(run) + return _c +} + +// NewMockHFDatasetComponent creates a new instance of MockHFDatasetComponent. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockHFDatasetComponent(t interface { + mock.TestingT + Cleanup(func()) +}) *MockHFDatasetComponent { + mock := &MockHFDatasetComponent{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/_mocks/opencsg.com/csghub-server/component/mock_LfsComponent.go b/_mocks/opencsg.com/csghub-server/component/mock_LfsComponent.go new file mode 100644 index 000000000..0da348590 --- /dev/null +++ b/_mocks/opencsg.com/csghub-server/component/mock_LfsComponent.go @@ -0,0 +1,77 @@ +// Code generated by mockery v2.53.5. DO NOT EDIT. + +package component + +import mock "github.com/stretchr/testify/mock" + +// MockLfsComponent is an autogenerated mock type for the LfsComponent type +type MockLfsComponent struct { + mock.Mock +} + +type MockLfsComponent_Expecter struct { + mock *mock.Mock +} + +func (_m *MockLfsComponent) EXPECT() *MockLfsComponent_Expecter { + return &MockLfsComponent_Expecter{mock: &_m.Mock} +} + +// DispatchLfsXnetProcessed provides a mock function with no fields +func (_m *MockLfsComponent) DispatchLfsXnetProcessed() error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for DispatchLfsXnetProcessed") + } + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockLfsComponent_DispatchLfsXnetProcessed_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DispatchLfsXnetProcessed' +type MockLfsComponent_DispatchLfsXnetProcessed_Call struct { + *mock.Call +} + +// DispatchLfsXnetProcessed is a helper method to define mock.On call +func (_e *MockLfsComponent_Expecter) DispatchLfsXnetProcessed() *MockLfsComponent_DispatchLfsXnetProcessed_Call { + return &MockLfsComponent_DispatchLfsXnetProcessed_Call{Call: _e.mock.On("DispatchLfsXnetProcessed")} +} + +func (_c *MockLfsComponent_DispatchLfsXnetProcessed_Call) Run(run func()) *MockLfsComponent_DispatchLfsXnetProcessed_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockLfsComponent_DispatchLfsXnetProcessed_Call) Return(_a0 error) *MockLfsComponent_DispatchLfsXnetProcessed_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockLfsComponent_DispatchLfsXnetProcessed_Call) RunAndReturn(run func() error) *MockLfsComponent_DispatchLfsXnetProcessed_Call { + _c.Call.Return(run) + return _c +} + +// NewMockLfsComponent creates a new instance of MockLfsComponent. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockLfsComponent(t interface { + mock.TestingT + Cleanup(func()) +}) *MockLfsComponent { + mock := &MockLfsComponent{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/_mocks/opencsg.com/csghub-server/component/mock_ListComponent.go b/_mocks/opencsg.com/csghub-server/component/mock_ListComponent.go new file mode 100644 index 000000000..1db2826fe --- /dev/null +++ b/_mocks/opencsg.com/csghub-server/component/mock_ListComponent.go @@ -0,0 +1,155 @@ +// Code generated by mockery v2.53.5. DO NOT EDIT. + +package component + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + types "opencsg.com/csghub-server/common/types" +) + +// MockListComponent is an autogenerated mock type for the ListComponent type +type MockListComponent struct { + mock.Mock +} + +type MockListComponent_Expecter struct { + mock *mock.Mock +} + +func (_m *MockListComponent) EXPECT() *MockListComponent_Expecter { + return &MockListComponent_Expecter{mock: &_m.Mock} +} + +// ListDatasetsByPath provides a mock function with given fields: ctx, req +func (_m *MockListComponent) ListDatasetsByPath(ctx context.Context, req *types.ListByPathReq) ([]*types.DatasetResp, error) { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for ListDatasetsByPath") + } + + var r0 []*types.DatasetResp + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *types.ListByPathReq) ([]*types.DatasetResp, error)); ok { + return rf(ctx, req) + } + if rf, ok := ret.Get(0).(func(context.Context, *types.ListByPathReq) []*types.DatasetResp); ok { + r0 = rf(ctx, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*types.DatasetResp) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *types.ListByPathReq) error); ok { + r1 = rf(ctx, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockListComponent_ListDatasetsByPath_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListDatasetsByPath' +type MockListComponent_ListDatasetsByPath_Call struct { + *mock.Call +} + +// ListDatasetsByPath is a helper method to define mock.On call +// - ctx context.Context +// - req *types.ListByPathReq +func (_e *MockListComponent_Expecter) ListDatasetsByPath(ctx interface{}, req interface{}) *MockListComponent_ListDatasetsByPath_Call { + return &MockListComponent_ListDatasetsByPath_Call{Call: _e.mock.On("ListDatasetsByPath", ctx, req)} +} + +func (_c *MockListComponent_ListDatasetsByPath_Call) Run(run func(ctx context.Context, req *types.ListByPathReq)) *MockListComponent_ListDatasetsByPath_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*types.ListByPathReq)) + }) + return _c +} + +func (_c *MockListComponent_ListDatasetsByPath_Call) Return(_a0 []*types.DatasetResp, _a1 error) *MockListComponent_ListDatasetsByPath_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockListComponent_ListDatasetsByPath_Call) RunAndReturn(run func(context.Context, *types.ListByPathReq) ([]*types.DatasetResp, error)) *MockListComponent_ListDatasetsByPath_Call { + _c.Call.Return(run) + return _c +} + +// ListModelsByPath provides a mock function with given fields: ctx, req +func (_m *MockListComponent) ListModelsByPath(ctx context.Context, req *types.ListByPathReq) ([]*types.ModelResp, error) { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for ListModelsByPath") + } + + var r0 []*types.ModelResp + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *types.ListByPathReq) ([]*types.ModelResp, error)); ok { + return rf(ctx, req) + } + if rf, ok := ret.Get(0).(func(context.Context, *types.ListByPathReq) []*types.ModelResp); ok { + r0 = rf(ctx, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]*types.ModelResp) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *types.ListByPathReq) error); ok { + r1 = rf(ctx, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockListComponent_ListModelsByPath_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListModelsByPath' +type MockListComponent_ListModelsByPath_Call struct { + *mock.Call +} + +// ListModelsByPath is a helper method to define mock.On call +// - ctx context.Context +// - req *types.ListByPathReq +func (_e *MockListComponent_Expecter) ListModelsByPath(ctx interface{}, req interface{}) *MockListComponent_ListModelsByPath_Call { + return &MockListComponent_ListModelsByPath_Call{Call: _e.mock.On("ListModelsByPath", ctx, req)} +} + +func (_c *MockListComponent_ListModelsByPath_Call) Run(run func(ctx context.Context, req *types.ListByPathReq)) *MockListComponent_ListModelsByPath_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*types.ListByPathReq)) + }) + return _c +} + +func (_c *MockListComponent_ListModelsByPath_Call) Return(_a0 []*types.ModelResp, _a1 error) *MockListComponent_ListModelsByPath_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockListComponent_ListModelsByPath_Call) RunAndReturn(run func(context.Context, *types.ListByPathReq) ([]*types.ModelResp, error)) *MockListComponent_ListModelsByPath_Call { + _c.Call.Return(run) + return _c +} + +// NewMockListComponent creates a new instance of MockListComponent. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockListComponent(t interface { + mock.TestingT + Cleanup(func()) +}) *MockListComponent { + mock := &MockListComponent{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/_mocks/opencsg.com/csghub-server/component/mock_RepoFileComponent.go b/_mocks/opencsg.com/csghub-server/component/mock_RepoFileComponent.go new file mode 100644 index 000000000..b7b697ee0 --- /dev/null +++ b/_mocks/opencsg.com/csghub-server/component/mock_RepoFileComponent.go @@ -0,0 +1,135 @@ +// Code generated by mockery v2.53.5. DO NOT EDIT. + +package component + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + types "opencsg.com/csghub-server/common/types" +) + +// MockRepoFileComponent is an autogenerated mock type for the RepoFileComponent type +type MockRepoFileComponent struct { + mock.Mock +} + +type MockRepoFileComponent_Expecter struct { + mock *mock.Mock +} + +func (_m *MockRepoFileComponent) EXPECT() *MockRepoFileComponent_Expecter { + return &MockRepoFileComponent_Expecter{mock: &_m.Mock} +} + +// GenRepoFileRecords provides a mock function with given fields: ctx, repoType, namespace, name +func (_m *MockRepoFileComponent) GenRepoFileRecords(ctx context.Context, repoType types.RepositoryType, namespace string, name string) error { + ret := _m.Called(ctx, repoType, namespace, name) + + if len(ret) == 0 { + panic("no return value specified for GenRepoFileRecords") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, types.RepositoryType, string, string) error); ok { + r0 = rf(ctx, repoType, namespace, name) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockRepoFileComponent_GenRepoFileRecords_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GenRepoFileRecords' +type MockRepoFileComponent_GenRepoFileRecords_Call struct { + *mock.Call +} + +// GenRepoFileRecords is a helper method to define mock.On call +// - ctx context.Context +// - repoType types.RepositoryType +// - namespace string +// - name string +func (_e *MockRepoFileComponent_Expecter) GenRepoFileRecords(ctx interface{}, repoType interface{}, namespace interface{}, name interface{}) *MockRepoFileComponent_GenRepoFileRecords_Call { + return &MockRepoFileComponent_GenRepoFileRecords_Call{Call: _e.mock.On("GenRepoFileRecords", ctx, repoType, namespace, name)} +} + +func (_c *MockRepoFileComponent_GenRepoFileRecords_Call) Run(run func(ctx context.Context, repoType types.RepositoryType, namespace string, name string)) *MockRepoFileComponent_GenRepoFileRecords_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(types.RepositoryType), args[2].(string), args[3].(string)) + }) + return _c +} + +func (_c *MockRepoFileComponent_GenRepoFileRecords_Call) Return(_a0 error) *MockRepoFileComponent_GenRepoFileRecords_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockRepoFileComponent_GenRepoFileRecords_Call) RunAndReturn(run func(context.Context, types.RepositoryType, string, string) error) *MockRepoFileComponent_GenRepoFileRecords_Call { + _c.Call.Return(run) + return _c +} + +// GenRepoFileRecordsBatch provides a mock function with given fields: ctx, repoType, lastRepoID, concurrency +func (_m *MockRepoFileComponent) GenRepoFileRecordsBatch(ctx context.Context, repoType types.RepositoryType, lastRepoID int64, concurrency int) error { + ret := _m.Called(ctx, repoType, lastRepoID, concurrency) + + if len(ret) == 0 { + panic("no return value specified for GenRepoFileRecordsBatch") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, types.RepositoryType, int64, int) error); ok { + r0 = rf(ctx, repoType, lastRepoID, concurrency) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockRepoFileComponent_GenRepoFileRecordsBatch_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GenRepoFileRecordsBatch' +type MockRepoFileComponent_GenRepoFileRecordsBatch_Call struct { + *mock.Call +} + +// GenRepoFileRecordsBatch is a helper method to define mock.On call +// - ctx context.Context +// - repoType types.RepositoryType +// - lastRepoID int64 +// - concurrency int +func (_e *MockRepoFileComponent_Expecter) GenRepoFileRecordsBatch(ctx interface{}, repoType interface{}, lastRepoID interface{}, concurrency interface{}) *MockRepoFileComponent_GenRepoFileRecordsBatch_Call { + return &MockRepoFileComponent_GenRepoFileRecordsBatch_Call{Call: _e.mock.On("GenRepoFileRecordsBatch", ctx, repoType, lastRepoID, concurrency)} +} + +func (_c *MockRepoFileComponent_GenRepoFileRecordsBatch_Call) Run(run func(ctx context.Context, repoType types.RepositoryType, lastRepoID int64, concurrency int)) *MockRepoFileComponent_GenRepoFileRecordsBatch_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(types.RepositoryType), args[2].(int64), args[3].(int)) + }) + return _c +} + +func (_c *MockRepoFileComponent_GenRepoFileRecordsBatch_Call) Return(_a0 error) *MockRepoFileComponent_GenRepoFileRecordsBatch_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockRepoFileComponent_GenRepoFileRecordsBatch_Call) RunAndReturn(run func(context.Context, types.RepositoryType, int64, int) error) *MockRepoFileComponent_GenRepoFileRecordsBatch_Call { + _c.Call.Return(run) + return _c +} + +// NewMockRepoFileComponent creates a new instance of MockRepoFileComponent. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockRepoFileComponent(t interface { + mock.TestingT + Cleanup(func()) +}) *MockRepoFileComponent { + mock := &MockRepoFileComponent{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/_mocks/opencsg.com/csghub-server/component/mock_SSHKeyComponent.go b/_mocks/opencsg.com/csghub-server/component/mock_SSHKeyComponent.go new file mode 100644 index 000000000..e424c605e --- /dev/null +++ b/_mocks/opencsg.com/csghub-server/component/mock_SSHKeyComponent.go @@ -0,0 +1,207 @@ +// Code generated by mockery v2.53.5. DO NOT EDIT. + +package component + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + database "opencsg.com/csghub-server/builder/store/database" + + types "opencsg.com/csghub-server/common/types" +) + +// MockSSHKeyComponent is an autogenerated mock type for the SSHKeyComponent type +type MockSSHKeyComponent struct { + mock.Mock +} + +type MockSSHKeyComponent_Expecter struct { + mock *mock.Mock +} + +func (_m *MockSSHKeyComponent) EXPECT() *MockSSHKeyComponent_Expecter { + return &MockSSHKeyComponent_Expecter{mock: &_m.Mock} +} + +// Create provides a mock function with given fields: ctx, req +func (_m *MockSSHKeyComponent) Create(ctx context.Context, req *types.CreateSSHKeyRequest) (*database.SSHKey, error) { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for Create") + } + + var r0 *database.SSHKey + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *types.CreateSSHKeyRequest) (*database.SSHKey, error)); ok { + return rf(ctx, req) + } + if rf, ok := ret.Get(0).(func(context.Context, *types.CreateSSHKeyRequest) *database.SSHKey); ok { + r0 = rf(ctx, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*database.SSHKey) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *types.CreateSSHKeyRequest) error); ok { + r1 = rf(ctx, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockSSHKeyComponent_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockSSHKeyComponent_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - req *types.CreateSSHKeyRequest +func (_e *MockSSHKeyComponent_Expecter) Create(ctx interface{}, req interface{}) *MockSSHKeyComponent_Create_Call { + return &MockSSHKeyComponent_Create_Call{Call: _e.mock.On("Create", ctx, req)} +} + +func (_c *MockSSHKeyComponent_Create_Call) Run(run func(ctx context.Context, req *types.CreateSSHKeyRequest)) *MockSSHKeyComponent_Create_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*types.CreateSSHKeyRequest)) + }) + return _c +} + +func (_c *MockSSHKeyComponent_Create_Call) Return(_a0 *database.SSHKey, _a1 error) *MockSSHKeyComponent_Create_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockSSHKeyComponent_Create_Call) RunAndReturn(run func(context.Context, *types.CreateSSHKeyRequest) (*database.SSHKey, error)) *MockSSHKeyComponent_Create_Call { + _c.Call.Return(run) + return _c +} + +// Delete provides a mock function with given fields: ctx, username, name +func (_m *MockSSHKeyComponent) Delete(ctx context.Context, username string, name string) error { + ret := _m.Called(ctx, username, name) + + if len(ret) == 0 { + panic("no return value specified for Delete") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok { + r0 = rf(ctx, username, name) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockSSHKeyComponent_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' +type MockSSHKeyComponent_Delete_Call struct { + *mock.Call +} + +// Delete is a helper method to define mock.On call +// - ctx context.Context +// - username string +// - name string +func (_e *MockSSHKeyComponent_Expecter) Delete(ctx interface{}, username interface{}, name interface{}) *MockSSHKeyComponent_Delete_Call { + return &MockSSHKeyComponent_Delete_Call{Call: _e.mock.On("Delete", ctx, username, name)} +} + +func (_c *MockSSHKeyComponent_Delete_Call) Run(run func(ctx context.Context, username string, name string)) *MockSSHKeyComponent_Delete_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string)) + }) + return _c +} + +func (_c *MockSSHKeyComponent_Delete_Call) Return(_a0 error) *MockSSHKeyComponent_Delete_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockSSHKeyComponent_Delete_Call) RunAndReturn(run func(context.Context, string, string) error) *MockSSHKeyComponent_Delete_Call { + _c.Call.Return(run) + return _c +} + +// Index provides a mock function with given fields: ctx, username, per, page +func (_m *MockSSHKeyComponent) Index(ctx context.Context, username string, per int, page int) ([]database.SSHKey, error) { + ret := _m.Called(ctx, username, per, page) + + if len(ret) == 0 { + panic("no return value specified for Index") + } + + var r0 []database.SSHKey + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, int, int) ([]database.SSHKey, error)); ok { + return rf(ctx, username, per, page) + } + if rf, ok := ret.Get(0).(func(context.Context, string, int, int) []database.SSHKey); ok { + r0 = rf(ctx, username, per, page) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]database.SSHKey) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string, int, int) error); ok { + r1 = rf(ctx, username, per, page) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockSSHKeyComponent_Index_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Index' +type MockSSHKeyComponent_Index_Call struct { + *mock.Call +} + +// Index is a helper method to define mock.On call +// - ctx context.Context +// - username string +// - per int +// - page int +func (_e *MockSSHKeyComponent_Expecter) Index(ctx interface{}, username interface{}, per interface{}, page interface{}) *MockSSHKeyComponent_Index_Call { + return &MockSSHKeyComponent_Index_Call{Call: _e.mock.On("Index", ctx, username, per, page)} +} + +func (_c *MockSSHKeyComponent_Index_Call) Run(run func(ctx context.Context, username string, per int, page int)) *MockSSHKeyComponent_Index_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(int), args[3].(int)) + }) + return _c +} + +func (_c *MockSSHKeyComponent_Index_Call) Return(_a0 []database.SSHKey, _a1 error) *MockSSHKeyComponent_Index_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockSSHKeyComponent_Index_Call) RunAndReturn(run func(context.Context, string, int, int) ([]database.SSHKey, error)) *MockSSHKeyComponent_Index_Call { + _c.Call.Return(run) + return _c +} + +// NewMockSSHKeyComponent creates a new instance of MockSSHKeyComponent. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockSSHKeyComponent(t interface { + mock.TestingT + Cleanup(func()) +}) *MockSSHKeyComponent { + mock := &MockSSHKeyComponent{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/_mocks/opencsg.com/csghub-server/component/mock_SpaceSdkComponent.go b/_mocks/opencsg.com/csghub-server/component/mock_SpaceSdkComponent.go new file mode 100644 index 000000000..f428cf12e --- /dev/null +++ b/_mocks/opencsg.com/csghub-server/component/mock_SpaceSdkComponent.go @@ -0,0 +1,260 @@ +// Code generated by mockery v2.53.5. DO NOT EDIT. + +package component + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + types "opencsg.com/csghub-server/common/types" +) + +// MockSpaceSdkComponent is an autogenerated mock type for the SpaceSdkComponent type +type MockSpaceSdkComponent struct { + mock.Mock +} + +type MockSpaceSdkComponent_Expecter struct { + mock *mock.Mock +} + +func (_m *MockSpaceSdkComponent) EXPECT() *MockSpaceSdkComponent_Expecter { + return &MockSpaceSdkComponent_Expecter{mock: &_m.Mock} +} + +// Create provides a mock function with given fields: ctx, req +func (_m *MockSpaceSdkComponent) Create(ctx context.Context, req *types.CreateSpaceSdkReq) (*types.SpaceSdk, error) { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for Create") + } + + var r0 *types.SpaceSdk + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *types.CreateSpaceSdkReq) (*types.SpaceSdk, error)); ok { + return rf(ctx, req) + } + if rf, ok := ret.Get(0).(func(context.Context, *types.CreateSpaceSdkReq) *types.SpaceSdk); ok { + r0 = rf(ctx, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.SpaceSdk) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *types.CreateSpaceSdkReq) error); ok { + r1 = rf(ctx, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockSpaceSdkComponent_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockSpaceSdkComponent_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - req *types.CreateSpaceSdkReq +func (_e *MockSpaceSdkComponent_Expecter) Create(ctx interface{}, req interface{}) *MockSpaceSdkComponent_Create_Call { + return &MockSpaceSdkComponent_Create_Call{Call: _e.mock.On("Create", ctx, req)} +} + +func (_c *MockSpaceSdkComponent_Create_Call) Run(run func(ctx context.Context, req *types.CreateSpaceSdkReq)) *MockSpaceSdkComponent_Create_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*types.CreateSpaceSdkReq)) + }) + return _c +} + +func (_c *MockSpaceSdkComponent_Create_Call) Return(_a0 *types.SpaceSdk, _a1 error) *MockSpaceSdkComponent_Create_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockSpaceSdkComponent_Create_Call) RunAndReturn(run func(context.Context, *types.CreateSpaceSdkReq) (*types.SpaceSdk, error)) *MockSpaceSdkComponent_Create_Call { + _c.Call.Return(run) + return _c +} + +// Delete provides a mock function with given fields: ctx, id +func (_m *MockSpaceSdkComponent) Delete(ctx context.Context, id int64) error { + ret := _m.Called(ctx, id) + + if len(ret) == 0 { + panic("no return value specified for Delete") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, int64) error); ok { + r0 = rf(ctx, id) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockSpaceSdkComponent_Delete_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Delete' +type MockSpaceSdkComponent_Delete_Call struct { + *mock.Call +} + +// Delete is a helper method to define mock.On call +// - ctx context.Context +// - id int64 +func (_e *MockSpaceSdkComponent_Expecter) Delete(ctx interface{}, id interface{}) *MockSpaceSdkComponent_Delete_Call { + return &MockSpaceSdkComponent_Delete_Call{Call: _e.mock.On("Delete", ctx, id)} +} + +func (_c *MockSpaceSdkComponent_Delete_Call) Run(run func(ctx context.Context, id int64)) *MockSpaceSdkComponent_Delete_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(int64)) + }) + return _c +} + +func (_c *MockSpaceSdkComponent_Delete_Call) Return(_a0 error) *MockSpaceSdkComponent_Delete_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockSpaceSdkComponent_Delete_Call) RunAndReturn(run func(context.Context, int64) error) *MockSpaceSdkComponent_Delete_Call { + _c.Call.Return(run) + return _c +} + +// Index provides a mock function with given fields: ctx +func (_m *MockSpaceSdkComponent) Index(ctx context.Context) ([]types.SpaceSdk, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for Index") + } + + var r0 []types.SpaceSdk + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) ([]types.SpaceSdk, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) []types.SpaceSdk); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]types.SpaceSdk) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockSpaceSdkComponent_Index_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Index' +type MockSpaceSdkComponent_Index_Call struct { + *mock.Call +} + +// Index is a helper method to define mock.On call +// - ctx context.Context +func (_e *MockSpaceSdkComponent_Expecter) Index(ctx interface{}) *MockSpaceSdkComponent_Index_Call { + return &MockSpaceSdkComponent_Index_Call{Call: _e.mock.On("Index", ctx)} +} + +func (_c *MockSpaceSdkComponent_Index_Call) Run(run func(ctx context.Context)) *MockSpaceSdkComponent_Index_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *MockSpaceSdkComponent_Index_Call) Return(_a0 []types.SpaceSdk, _a1 error) *MockSpaceSdkComponent_Index_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockSpaceSdkComponent_Index_Call) RunAndReturn(run func(context.Context) ([]types.SpaceSdk, error)) *MockSpaceSdkComponent_Index_Call { + _c.Call.Return(run) + return _c +} + +// Update provides a mock function with given fields: ctx, req +func (_m *MockSpaceSdkComponent) Update(ctx context.Context, req *types.UpdateSpaceSdkReq) (*types.SpaceSdk, error) { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for Update") + } + + var r0 *types.SpaceSdk + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, *types.UpdateSpaceSdkReq) (*types.SpaceSdk, error)); ok { + return rf(ctx, req) + } + if rf, ok := ret.Get(0).(func(context.Context, *types.UpdateSpaceSdkReq) *types.SpaceSdk); ok { + r0 = rf(ctx, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*types.SpaceSdk) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, *types.UpdateSpaceSdkReq) error); ok { + r1 = rf(ctx, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockSpaceSdkComponent_Update_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Update' +type MockSpaceSdkComponent_Update_Call struct { + *mock.Call +} + +// Update is a helper method to define mock.On call +// - ctx context.Context +// - req *types.UpdateSpaceSdkReq +func (_e *MockSpaceSdkComponent_Expecter) Update(ctx interface{}, req interface{}) *MockSpaceSdkComponent_Update_Call { + return &MockSpaceSdkComponent_Update_Call{Call: _e.mock.On("Update", ctx, req)} +} + +func (_c *MockSpaceSdkComponent_Update_Call) Run(run func(ctx context.Context, req *types.UpdateSpaceSdkReq)) *MockSpaceSdkComponent_Update_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*types.UpdateSpaceSdkReq)) + }) + return _c +} + +func (_c *MockSpaceSdkComponent_Update_Call) Return(_a0 *types.SpaceSdk, _a1 error) *MockSpaceSdkComponent_Update_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockSpaceSdkComponent_Update_Call) RunAndReturn(run func(context.Context, *types.UpdateSpaceSdkReq) (*types.SpaceSdk, error)) *MockSpaceSdkComponent_Update_Call { + _c.Call.Return(run) + return _c +} + +// NewMockSpaceSdkComponent creates a new instance of MockSpaceSdkComponent. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockSpaceSdkComponent(t interface { + mock.TestingT + Cleanup(func()) +}) *MockSpaceSdkComponent { + mock := &MockSpaceSdkComponent{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/_mocks/opencsg.com/csghub-server/component/mock_SyncClientSettingComponent.go b/_mocks/opencsg.com/csghub-server/component/mock_SyncClientSettingComponent.go new file mode 100644 index 000000000..5d6424c04 --- /dev/null +++ b/_mocks/opencsg.com/csghub-server/component/mock_SyncClientSettingComponent.go @@ -0,0 +1,156 @@ +// Code generated by mockery v2.53.5. DO NOT EDIT. + +package component + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + database "opencsg.com/csghub-server/builder/store/database" + + types "opencsg.com/csghub-server/common/types" +) + +// MockSyncClientSettingComponent is an autogenerated mock type for the SyncClientSettingComponent type +type MockSyncClientSettingComponent struct { + mock.Mock +} + +type MockSyncClientSettingComponent_Expecter struct { + mock *mock.Mock +} + +func (_m *MockSyncClientSettingComponent) EXPECT() *MockSyncClientSettingComponent_Expecter { + return &MockSyncClientSettingComponent_Expecter{mock: &_m.Mock} +} + +// Create provides a mock function with given fields: ctx, req +func (_m *MockSyncClientSettingComponent) Create(ctx context.Context, req types.CreateSyncClientSettingReq) (*database.SyncClientSetting, error) { + ret := _m.Called(ctx, req) + + if len(ret) == 0 { + panic("no return value specified for Create") + } + + var r0 *database.SyncClientSetting + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, types.CreateSyncClientSettingReq) (*database.SyncClientSetting, error)); ok { + return rf(ctx, req) + } + if rf, ok := ret.Get(0).(func(context.Context, types.CreateSyncClientSettingReq) *database.SyncClientSetting); ok { + r0 = rf(ctx, req) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*database.SyncClientSetting) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, types.CreateSyncClientSettingReq) error); ok { + r1 = rf(ctx, req) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockSyncClientSettingComponent_Create_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Create' +type MockSyncClientSettingComponent_Create_Call struct { + *mock.Call +} + +// Create is a helper method to define mock.On call +// - ctx context.Context +// - req types.CreateSyncClientSettingReq +func (_e *MockSyncClientSettingComponent_Expecter) Create(ctx interface{}, req interface{}) *MockSyncClientSettingComponent_Create_Call { + return &MockSyncClientSettingComponent_Create_Call{Call: _e.mock.On("Create", ctx, req)} +} + +func (_c *MockSyncClientSettingComponent_Create_Call) Run(run func(ctx context.Context, req types.CreateSyncClientSettingReq)) *MockSyncClientSettingComponent_Create_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(types.CreateSyncClientSettingReq)) + }) + return _c +} + +func (_c *MockSyncClientSettingComponent_Create_Call) Return(_a0 *database.SyncClientSetting, _a1 error) *MockSyncClientSettingComponent_Create_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockSyncClientSettingComponent_Create_Call) RunAndReturn(run func(context.Context, types.CreateSyncClientSettingReq) (*database.SyncClientSetting, error)) *MockSyncClientSettingComponent_Create_Call { + _c.Call.Return(run) + return _c +} + +// Show provides a mock function with given fields: ctx +func (_m *MockSyncClientSettingComponent) Show(ctx context.Context) (*database.SyncClientSetting, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for Show") + } + + var r0 *database.SyncClientSetting + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) (*database.SyncClientSetting, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) *database.SyncClientSetting); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).(*database.SyncClientSetting) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockSyncClientSettingComponent_Show_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Show' +type MockSyncClientSettingComponent_Show_Call struct { + *mock.Call +} + +// Show is a helper method to define mock.On call +// - ctx context.Context +func (_e *MockSyncClientSettingComponent_Expecter) Show(ctx interface{}) *MockSyncClientSettingComponent_Show_Call { + return &MockSyncClientSettingComponent_Show_Call{Call: _e.mock.On("Show", ctx)} +} + +func (_c *MockSyncClientSettingComponent_Show_Call) Run(run func(ctx context.Context)) *MockSyncClientSettingComponent_Show_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *MockSyncClientSettingComponent_Show_Call) Return(_a0 *database.SyncClientSetting, _a1 error) *MockSyncClientSettingComponent_Show_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockSyncClientSettingComponent_Show_Call) RunAndReturn(run func(context.Context) (*database.SyncClientSetting, error)) *MockSyncClientSettingComponent_Show_Call { + _c.Call.Return(run) + return _c +} + +// NewMockSyncClientSettingComponent creates a new instance of MockSyncClientSettingComponent. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockSyncClientSettingComponent(t interface { + mock.TestingT + Cleanup(func()) +}) *MockSyncClientSettingComponent { + mock := &MockSyncClientSettingComponent{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/_mocks/opencsg.com/csghub-server/component/mock_TelemetryComponent.go b/_mocks/opencsg.com/csghub-server/component/mock_TelemetryComponent.go new file mode 100644 index 000000000..2103a60fa --- /dev/null +++ b/_mocks/opencsg.com/csghub-server/component/mock_TelemetryComponent.go @@ -0,0 +1,140 @@ +// Code generated by mockery v2.53.5. DO NOT EDIT. + +package component + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + telemetry "opencsg.com/csghub-server/common/types/telemetry" +) + +// MockTelemetryComponent is an autogenerated mock type for the TelemetryComponent type +type MockTelemetryComponent struct { + mock.Mock +} + +type MockTelemetryComponent_Expecter struct { + mock *mock.Mock +} + +func (_m *MockTelemetryComponent) EXPECT() *MockTelemetryComponent_Expecter { + return &MockTelemetryComponent_Expecter{mock: &_m.Mock} +} + +// GenUsageData provides a mock function with given fields: ctx +func (_m *MockTelemetryComponent) GenUsageData(ctx context.Context) (telemetry.Usage, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for GenUsageData") + } + + var r0 telemetry.Usage + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) (telemetry.Usage, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) telemetry.Usage); ok { + r0 = rf(ctx) + } else { + r0 = ret.Get(0).(telemetry.Usage) + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockTelemetryComponent_GenUsageData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GenUsageData' +type MockTelemetryComponent_GenUsageData_Call struct { + *mock.Call +} + +// GenUsageData is a helper method to define mock.On call +// - ctx context.Context +func (_e *MockTelemetryComponent_Expecter) GenUsageData(ctx interface{}) *MockTelemetryComponent_GenUsageData_Call { + return &MockTelemetryComponent_GenUsageData_Call{Call: _e.mock.On("GenUsageData", ctx)} +} + +func (_c *MockTelemetryComponent_GenUsageData_Call) Run(run func(ctx context.Context)) *MockTelemetryComponent_GenUsageData_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *MockTelemetryComponent_GenUsageData_Call) Return(_a0 telemetry.Usage, _a1 error) *MockTelemetryComponent_GenUsageData_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockTelemetryComponent_GenUsageData_Call) RunAndReturn(run func(context.Context) (telemetry.Usage, error)) *MockTelemetryComponent_GenUsageData_Call { + _c.Call.Return(run) + return _c +} + +// SaveUsageData provides a mock function with given fields: ctx, usage +func (_m *MockTelemetryComponent) SaveUsageData(ctx context.Context, usage telemetry.Usage) error { + ret := _m.Called(ctx, usage) + + if len(ret) == 0 { + panic("no return value specified for SaveUsageData") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, telemetry.Usage) error); ok { + r0 = rf(ctx, usage) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockTelemetryComponent_SaveUsageData_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SaveUsageData' +type MockTelemetryComponent_SaveUsageData_Call struct { + *mock.Call +} + +// SaveUsageData is a helper method to define mock.On call +// - ctx context.Context +// - usage telemetry.Usage +func (_e *MockTelemetryComponent_Expecter) SaveUsageData(ctx interface{}, usage interface{}) *MockTelemetryComponent_SaveUsageData_Call { + return &MockTelemetryComponent_SaveUsageData_Call{Call: _e.mock.On("SaveUsageData", ctx, usage)} +} + +func (_c *MockTelemetryComponent_SaveUsageData_Call) Run(run func(ctx context.Context, usage telemetry.Usage)) *MockTelemetryComponent_SaveUsageData_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(telemetry.Usage)) + }) + return _c +} + +func (_c *MockTelemetryComponent_SaveUsageData_Call) Return(_a0 error) *MockTelemetryComponent_SaveUsageData_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockTelemetryComponent_SaveUsageData_Call) RunAndReturn(run func(context.Context, telemetry.Usage) error) *MockTelemetryComponent_SaveUsageData_Call { + _c.Call.Return(run) + return _c +} + +// NewMockTelemetryComponent creates a new instance of MockTelemetryComponent. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockTelemetryComponent(t interface { + mock.TestingT + Cleanup(func()) +}) *MockTelemetryComponent { + mock := &MockTelemetryComponent{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/_mocks/opencsg.com/csghub-server/component/mock_WebHookComponent.go b/_mocks/opencsg.com/csghub-server/component/mock_WebHookComponent.go new file mode 100644 index 000000000..8d700ae53 --- /dev/null +++ b/_mocks/opencsg.com/csghub-server/component/mock_WebHookComponent.go @@ -0,0 +1,129 @@ +// Code generated by mockery v2.53.5. DO NOT EDIT. + +package component + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + types "opencsg.com/csghub-server/common/types" +) + +// MockWebHookComponent is an autogenerated mock type for the WebHookComponent type +type MockWebHookComponent struct { + mock.Mock +} + +type MockWebHookComponent_Expecter struct { + mock *mock.Mock +} + +func (_m *MockWebHookComponent) EXPECT() *MockWebHookComponent_Expecter { + return &MockWebHookComponent_Expecter{mock: &_m.Mock} +} + +// DispatchWebHookEvent provides a mock function with no fields +func (_m *MockWebHookComponent) DispatchWebHookEvent() error { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for DispatchWebHookEvent") + } + + var r0 error + if rf, ok := ret.Get(0).(func() error); ok { + r0 = rf() + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockWebHookComponent_DispatchWebHookEvent_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DispatchWebHookEvent' +type MockWebHookComponent_DispatchWebHookEvent_Call struct { + *mock.Call +} + +// DispatchWebHookEvent is a helper method to define mock.On call +func (_e *MockWebHookComponent_Expecter) DispatchWebHookEvent() *MockWebHookComponent_DispatchWebHookEvent_Call { + return &MockWebHookComponent_DispatchWebHookEvent_Call{Call: _e.mock.On("DispatchWebHookEvent")} +} + +func (_c *MockWebHookComponent_DispatchWebHookEvent_Call) Run(run func()) *MockWebHookComponent_DispatchWebHookEvent_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockWebHookComponent_DispatchWebHookEvent_Call) Return(_a0 error) *MockWebHookComponent_DispatchWebHookEvent_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockWebHookComponent_DispatchWebHookEvent_Call) RunAndReturn(run func() error) *MockWebHookComponent_DispatchWebHookEvent_Call { + _c.Call.Return(run) + return _c +} + +// HandleWebHook provides a mock function with given fields: ctx, event +func (_m *MockWebHookComponent) HandleWebHook(ctx context.Context, event *types.WebHookRecvEvent) error { + ret := _m.Called(ctx, event) + + if len(ret) == 0 { + panic("no return value specified for HandleWebHook") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, *types.WebHookRecvEvent) error); ok { + r0 = rf(ctx, event) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockWebHookComponent_HandleWebHook_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'HandleWebHook' +type MockWebHookComponent_HandleWebHook_Call struct { + *mock.Call +} + +// HandleWebHook is a helper method to define mock.On call +// - ctx context.Context +// - event *types.WebHookRecvEvent +func (_e *MockWebHookComponent_Expecter) HandleWebHook(ctx interface{}, event interface{}) *MockWebHookComponent_HandleWebHook_Call { + return &MockWebHookComponent_HandleWebHook_Call{Call: _e.mock.On("HandleWebHook", ctx, event)} +} + +func (_c *MockWebHookComponent_HandleWebHook_Call) Run(run func(ctx context.Context, event *types.WebHookRecvEvent)) *MockWebHookComponent_HandleWebHook_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(*types.WebHookRecvEvent)) + }) + return _c +} + +func (_c *MockWebHookComponent_HandleWebHook_Call) Return(_a0 error) *MockWebHookComponent_HandleWebHook_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockWebHookComponent_HandleWebHook_Call) RunAndReturn(run func(context.Context, *types.WebHookRecvEvent) error) *MockWebHookComponent_HandleWebHook_Call { + _c.Call.Return(run) + return _c +} + +// NewMockWebHookComponent creates a new instance of MockWebHookComponent. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockWebHookComponent(t interface { + mock.TestingT + Cleanup(func()) +}) *MockWebHookComponent { + mock := &MockWebHookComponent{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/_mocks/opencsg.com/csghub-server/component/mock_deleteKnowledgeBaseCsgbotFn.go b/_mocks/opencsg.com/csghub-server/component/mock_deleteKnowledgeBaseCsgbotFn.go new file mode 100644 index 000000000..b0b6844fd --- /dev/null +++ b/_mocks/opencsg.com/csghub-server/component/mock_deleteKnowledgeBaseCsgbotFn.go @@ -0,0 +1,84 @@ +// Code generated by mockery v2.53.5. DO NOT EDIT. + +package component + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" +) + +// MockdeleteKnowledgeBaseCsgbotFn is an autogenerated mock type for the deleteKnowledgeBaseCsgbotFn type +type MockdeleteKnowledgeBaseCsgbotFn struct { + mock.Mock +} + +type MockdeleteKnowledgeBaseCsgbotFn_Expecter struct { + mock *mock.Mock +} + +func (_m *MockdeleteKnowledgeBaseCsgbotFn) EXPECT() *MockdeleteKnowledgeBaseCsgbotFn_Expecter { + return &MockdeleteKnowledgeBaseCsgbotFn_Expecter{mock: &_m.Mock} +} + +// Execute provides a mock function with given fields: ctx, userUUID, contentID +func (_m *MockdeleteKnowledgeBaseCsgbotFn) Execute(ctx context.Context, userUUID string, contentID string) error { + ret := _m.Called(ctx, userUUID, contentID) + + if len(ret) == 0 { + panic("no return value specified for Execute") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, string) error); ok { + r0 = rf(ctx, userUUID, contentID) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockdeleteKnowledgeBaseCsgbotFn_Execute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Execute' +type MockdeleteKnowledgeBaseCsgbotFn_Execute_Call struct { + *mock.Call +} + +// Execute is a helper method to define mock.On call +// - ctx context.Context +// - userUUID string +// - contentID string +func (_e *MockdeleteKnowledgeBaseCsgbotFn_Expecter) Execute(ctx interface{}, userUUID interface{}, contentID interface{}) *MockdeleteKnowledgeBaseCsgbotFn_Execute_Call { + return &MockdeleteKnowledgeBaseCsgbotFn_Execute_Call{Call: _e.mock.On("Execute", ctx, userUUID, contentID)} +} + +func (_c *MockdeleteKnowledgeBaseCsgbotFn_Execute_Call) Run(run func(ctx context.Context, userUUID string, contentID string)) *MockdeleteKnowledgeBaseCsgbotFn_Execute_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string)) + }) + return _c +} + +func (_c *MockdeleteKnowledgeBaseCsgbotFn_Execute_Call) Return(_a0 error) *MockdeleteKnowledgeBaseCsgbotFn_Execute_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockdeleteKnowledgeBaseCsgbotFn_Execute_Call) RunAndReturn(run func(context.Context, string, string) error) *MockdeleteKnowledgeBaseCsgbotFn_Execute_Call { + _c.Call.Return(run) + return _c +} + +// NewMockdeleteKnowledgeBaseCsgbotFn creates a new instance of MockdeleteKnowledgeBaseCsgbotFn. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockdeleteKnowledgeBaseCsgbotFn(t interface { + mock.TestingT + Cleanup(func()) +}) *MockdeleteKnowledgeBaseCsgbotFn { + mock := &MockdeleteKnowledgeBaseCsgbotFn{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/_mocks/opencsg.com/csghub-server/component/mock_updateKnowledgeBaseCsgbotFn.go b/_mocks/opencsg.com/csghub-server/component/mock_updateKnowledgeBaseCsgbotFn.go new file mode 100644 index 000000000..91e84f83b --- /dev/null +++ b/_mocks/opencsg.com/csghub-server/component/mock_updateKnowledgeBaseCsgbotFn.go @@ -0,0 +1,85 @@ +// Code generated by mockery v2.53.5. DO NOT EDIT. + +package component + +import ( + context "context" + + mock "github.com/stretchr/testify/mock" + types "opencsg.com/csghub-server/common/types" +) + +// MockupdateKnowledgeBaseCsgbotFn is an autogenerated mock type for the updateKnowledgeBaseCsgbotFn type +type MockupdateKnowledgeBaseCsgbotFn struct { + mock.Mock +} + +type MockupdateKnowledgeBaseCsgbotFn_Expecter struct { + mock *mock.Mock +} + +func (_m *MockupdateKnowledgeBaseCsgbotFn) EXPECT() *MockupdateKnowledgeBaseCsgbotFn_Expecter { + return &MockupdateKnowledgeBaseCsgbotFn_Expecter{mock: &_m.Mock} +} + +// Execute provides a mock function with given fields: ctx, contentID, req +func (_m *MockupdateKnowledgeBaseCsgbotFn) Execute(ctx context.Context, contentID string, req *types.UpdateAgentKnowledgeBaseRequest) error { + ret := _m.Called(ctx, contentID, req) + + if len(ret) == 0 { + panic("no return value specified for Execute") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, *types.UpdateAgentKnowledgeBaseRequest) error); ok { + r0 = rf(ctx, contentID, req) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockupdateKnowledgeBaseCsgbotFn_Execute_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'Execute' +type MockupdateKnowledgeBaseCsgbotFn_Execute_Call struct { + *mock.Call +} + +// Execute is a helper method to define mock.On call +// - ctx context.Context +// - contentID string +// - req *types.UpdateAgentKnowledgeBaseRequest +func (_e *MockupdateKnowledgeBaseCsgbotFn_Expecter) Execute(ctx interface{}, contentID interface{}, req interface{}) *MockupdateKnowledgeBaseCsgbotFn_Execute_Call { + return &MockupdateKnowledgeBaseCsgbotFn_Execute_Call{Call: _e.mock.On("Execute", ctx, contentID, req)} +} + +func (_c *MockupdateKnowledgeBaseCsgbotFn_Execute_Call) Run(run func(ctx context.Context, contentID string, req *types.UpdateAgentKnowledgeBaseRequest)) *MockupdateKnowledgeBaseCsgbotFn_Execute_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(*types.UpdateAgentKnowledgeBaseRequest)) + }) + return _c +} + +func (_c *MockupdateKnowledgeBaseCsgbotFn_Execute_Call) Return(_a0 error) *MockupdateKnowledgeBaseCsgbotFn_Execute_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockupdateKnowledgeBaseCsgbotFn_Execute_Call) RunAndReturn(run func(context.Context, string, *types.UpdateAgentKnowledgeBaseRequest) error) *MockupdateKnowledgeBaseCsgbotFn_Execute_Call { + _c.Call.Return(run) + return _c +} + +// NewMockupdateKnowledgeBaseCsgbotFn creates a new instance of MockupdateKnowledgeBaseCsgbotFn. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockupdateKnowledgeBaseCsgbotFn(t interface { + mock.TestingT + Cleanup(func()) +}) *MockupdateKnowledgeBaseCsgbotFn { + mock := &MockupdateKnowledgeBaseCsgbotFn{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/_mocks/opencsg.com/csghub-server/notification/notifychannel/channel/lark/cache/mock_LarkCache.go b/_mocks/opencsg.com/csghub-server/notification/notifychannel/channel/lark/cache/mock_LarkCache.go new file mode 100644 index 000000000..82a041f94 --- /dev/null +++ b/_mocks/opencsg.com/csghub-server/notification/notifychannel/channel/lark/cache/mock_LarkCache.go @@ -0,0 +1,467 @@ +// Code generated by mockery v2.53.5. DO NOT EDIT. + +package cache + +import ( + context "context" + time "time" + + mock "github.com/stretchr/testify/mock" + + types "opencsg.com/csghub-server/common/types" +) + +// MockLarkCache is an autogenerated mock type for the LarkCache type +type MockLarkCache struct { + mock.Mock +} + +type MockLarkCache_Expecter struct { + mock *mock.Mock +} + +func (_m *MockLarkCache) EXPECT() *MockLarkCache_Expecter { + return &MockLarkCache_Expecter{mock: &_m.Mock} +} + +// BatchPopMessages provides a mock function with given fields: ctx, receiveIDType, receiveID, max +func (_m *MockLarkCache) BatchPopMessages(ctx context.Context, receiveIDType types.LarkMessageReceiveIDType, receiveID string, max int) ([]types.LarkMessage, error) { + ret := _m.Called(ctx, receiveIDType, receiveID, max) + + if len(ret) == 0 { + panic("no return value specified for BatchPopMessages") + } + + var r0 []types.LarkMessage + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, types.LarkMessageReceiveIDType, string, int) ([]types.LarkMessage, error)); ok { + return rf(ctx, receiveIDType, receiveID, max) + } + if rf, ok := ret.Get(0).(func(context.Context, types.LarkMessageReceiveIDType, string, int) []types.LarkMessage); ok { + r0 = rf(ctx, receiveIDType, receiveID, max) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]types.LarkMessage) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, types.LarkMessageReceiveIDType, string, int) error); ok { + r1 = rf(ctx, receiveIDType, receiveID, max) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockLarkCache_BatchPopMessages_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'BatchPopMessages' +type MockLarkCache_BatchPopMessages_Call struct { + *mock.Call +} + +// BatchPopMessages is a helper method to define mock.On call +// - ctx context.Context +// - receiveIDType types.LarkMessageReceiveIDType +// - receiveID string +// - max int +func (_e *MockLarkCache_Expecter) BatchPopMessages(ctx interface{}, receiveIDType interface{}, receiveID interface{}, max interface{}) *MockLarkCache_BatchPopMessages_Call { + return &MockLarkCache_BatchPopMessages_Call{Call: _e.mock.On("BatchPopMessages", ctx, receiveIDType, receiveID, max)} +} + +func (_c *MockLarkCache_BatchPopMessages_Call) Run(run func(ctx context.Context, receiveIDType types.LarkMessageReceiveIDType, receiveID string, max int)) *MockLarkCache_BatchPopMessages_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(types.LarkMessageReceiveIDType), args[2].(string), args[3].(int)) + }) + return _c +} + +func (_c *MockLarkCache_BatchPopMessages_Call) Return(_a0 []types.LarkMessage, _a1 error) *MockLarkCache_BatchPopMessages_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockLarkCache_BatchPopMessages_Call) RunAndReturn(run func(context.Context, types.LarkMessageReceiveIDType, string, int) ([]types.LarkMessage, error)) *MockLarkCache_BatchPopMessages_Call { + _c.Call.Return(run) + return _c +} + +// CleanChatIDs provides a mock function with given fields: ctx, appID +func (_m *MockLarkCache) CleanChatIDs(ctx context.Context, appID string) error { + ret := _m.Called(ctx, appID) + + if len(ret) == 0 { + panic("no return value specified for CleanChatIDs") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string) error); ok { + r0 = rf(ctx, appID) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockLarkCache_CleanChatIDs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CleanChatIDs' +type MockLarkCache_CleanChatIDs_Call struct { + *mock.Call +} + +// CleanChatIDs is a helper method to define mock.On call +// - ctx context.Context +// - appID string +func (_e *MockLarkCache_Expecter) CleanChatIDs(ctx interface{}, appID interface{}) *MockLarkCache_CleanChatIDs_Call { + return &MockLarkCache_CleanChatIDs_Call{Call: _e.mock.On("CleanChatIDs", ctx, appID)} +} + +func (_c *MockLarkCache_CleanChatIDs_Call) Run(run func(ctx context.Context, appID string)) *MockLarkCache_CleanChatIDs_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockLarkCache_CleanChatIDs_Call) Return(_a0 error) *MockLarkCache_CleanChatIDs_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockLarkCache_CleanChatIDs_Call) RunAndReturn(run func(context.Context, string) error) *MockLarkCache_CleanChatIDs_Call { + _c.Call.Return(run) + return _c +} + +// GetChatIDs provides a mock function with given fields: ctx, appID +func (_m *MockLarkCache) GetChatIDs(ctx context.Context, appID string) ([]string, error) { + ret := _m.Called(ctx, appID) + + if len(ret) == 0 { + panic("no return value specified for GetChatIDs") + } + + var r0 []string + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) ([]string, error)); ok { + return rf(ctx, appID) + } + if rf, ok := ret.Get(0).(func(context.Context, string) []string); ok { + r0 = rf(ctx, appID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]string) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, appID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockLarkCache_GetChatIDs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetChatIDs' +type MockLarkCache_GetChatIDs_Call struct { + *mock.Call +} + +// GetChatIDs is a helper method to define mock.On call +// - ctx context.Context +// - appID string +func (_e *MockLarkCache_Expecter) GetChatIDs(ctx interface{}, appID interface{}) *MockLarkCache_GetChatIDs_Call { + return &MockLarkCache_GetChatIDs_Call{Call: _e.mock.On("GetChatIDs", ctx, appID)} +} + +func (_c *MockLarkCache_GetChatIDs_Call) Run(run func(ctx context.Context, appID string)) *MockLarkCache_GetChatIDs_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockLarkCache_GetChatIDs_Call) Return(_a0 []string, _a1 error) *MockLarkCache_GetChatIDs_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockLarkCache_GetChatIDs_Call) RunAndReturn(run func(context.Context, string) ([]string, error)) *MockLarkCache_GetChatIDs_Call { + _c.Call.Return(run) + return _c +} + +// GetReceiveIDs provides a mock function with given fields: ctx +func (_m *MockLarkCache) GetReceiveIDs(ctx context.Context) ([]string, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for GetReceiveIDs") + } + + var r0 []string + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) ([]string, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) []string); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]string) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockLarkCache_GetReceiveIDs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetReceiveIDs' +type MockLarkCache_GetReceiveIDs_Call struct { + *mock.Call +} + +// GetReceiveIDs is a helper method to define mock.On call +// - ctx context.Context +func (_e *MockLarkCache_Expecter) GetReceiveIDs(ctx interface{}) *MockLarkCache_GetReceiveIDs_Call { + return &MockLarkCache_GetReceiveIDs_Call{Call: _e.mock.On("GetReceiveIDs", ctx)} +} + +func (_c *MockLarkCache_GetReceiveIDs_Call) Run(run func(ctx context.Context)) *MockLarkCache_GetReceiveIDs_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *MockLarkCache_GetReceiveIDs_Call) Return(_a0 []string, _a1 error) *MockLarkCache_GetReceiveIDs_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockLarkCache_GetReceiveIDs_Call) RunAndReturn(run func(context.Context) ([]string, error)) *MockLarkCache_GetReceiveIDs_Call { + _c.Call.Return(run) + return _c +} + +// PopMessage provides a mock function with given fields: ctx, receiveIDType, receiveID +func (_m *MockLarkCache) PopMessage(ctx context.Context, receiveIDType types.LarkMessageReceiveIDType, receiveID string) (types.LarkMessage, error) { + ret := _m.Called(ctx, receiveIDType, receiveID) + + if len(ret) == 0 { + panic("no return value specified for PopMessage") + } + + var r0 types.LarkMessage + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, types.LarkMessageReceiveIDType, string) (types.LarkMessage, error)); ok { + return rf(ctx, receiveIDType, receiveID) + } + if rf, ok := ret.Get(0).(func(context.Context, types.LarkMessageReceiveIDType, string) types.LarkMessage); ok { + r0 = rf(ctx, receiveIDType, receiveID) + } else { + r0 = ret.Get(0).(types.LarkMessage) + } + + if rf, ok := ret.Get(1).(func(context.Context, types.LarkMessageReceiveIDType, string) error); ok { + r1 = rf(ctx, receiveIDType, receiveID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockLarkCache_PopMessage_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PopMessage' +type MockLarkCache_PopMessage_Call struct { + *mock.Call +} + +// PopMessage is a helper method to define mock.On call +// - ctx context.Context +// - receiveIDType types.LarkMessageReceiveIDType +// - receiveID string +func (_e *MockLarkCache_Expecter) PopMessage(ctx interface{}, receiveIDType interface{}, receiveID interface{}) *MockLarkCache_PopMessage_Call { + return &MockLarkCache_PopMessage_Call{Call: _e.mock.On("PopMessage", ctx, receiveIDType, receiveID)} +} + +func (_c *MockLarkCache_PopMessage_Call) Run(run func(ctx context.Context, receiveIDType types.LarkMessageReceiveIDType, receiveID string)) *MockLarkCache_PopMessage_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(types.LarkMessageReceiveIDType), args[2].(string)) + }) + return _c +} + +func (_c *MockLarkCache_PopMessage_Call) Return(_a0 types.LarkMessage, _a1 error) *MockLarkCache_PopMessage_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockLarkCache_PopMessage_Call) RunAndReturn(run func(context.Context, types.LarkMessageReceiveIDType, string) (types.LarkMessage, error)) *MockLarkCache_PopMessage_Call { + _c.Call.Return(run) + return _c +} + +// PushBackMessages provides a mock function with given fields: ctx, receiveIDType, receiveID, messages +func (_m *MockLarkCache) PushBackMessages(ctx context.Context, receiveIDType types.LarkMessageReceiveIDType, receiveID string, messages []types.LarkMessage) error { + ret := _m.Called(ctx, receiveIDType, receiveID, messages) + + if len(ret) == 0 { + panic("no return value specified for PushBackMessages") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, types.LarkMessageReceiveIDType, string, []types.LarkMessage) error); ok { + r0 = rf(ctx, receiveIDType, receiveID, messages) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockLarkCache_PushBackMessages_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PushBackMessages' +type MockLarkCache_PushBackMessages_Call struct { + *mock.Call +} + +// PushBackMessages is a helper method to define mock.On call +// - ctx context.Context +// - receiveIDType types.LarkMessageReceiveIDType +// - receiveID string +// - messages []types.LarkMessage +func (_e *MockLarkCache_Expecter) PushBackMessages(ctx interface{}, receiveIDType interface{}, receiveID interface{}, messages interface{}) *MockLarkCache_PushBackMessages_Call { + return &MockLarkCache_PushBackMessages_Call{Call: _e.mock.On("PushBackMessages", ctx, receiveIDType, receiveID, messages)} +} + +func (_c *MockLarkCache_PushBackMessages_Call) Run(run func(ctx context.Context, receiveIDType types.LarkMessageReceiveIDType, receiveID string, messages []types.LarkMessage)) *MockLarkCache_PushBackMessages_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(types.LarkMessageReceiveIDType), args[2].(string), args[3].([]types.LarkMessage)) + }) + return _c +} + +func (_c *MockLarkCache_PushBackMessages_Call) Return(_a0 error) *MockLarkCache_PushBackMessages_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockLarkCache_PushBackMessages_Call) RunAndReturn(run func(context.Context, types.LarkMessageReceiveIDType, string, []types.LarkMessage) error) *MockLarkCache_PushBackMessages_Call { + _c.Call.Return(run) + return _c +} + +// PushMessage provides a mock function with given fields: ctx, message +func (_m *MockLarkCache) PushMessage(ctx context.Context, message types.LarkMessage) error { + ret := _m.Called(ctx, message) + + if len(ret) == 0 { + panic("no return value specified for PushMessage") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, types.LarkMessage) error); ok { + r0 = rf(ctx, message) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockLarkCache_PushMessage_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'PushMessage' +type MockLarkCache_PushMessage_Call struct { + *mock.Call +} + +// PushMessage is a helper method to define mock.On call +// - ctx context.Context +// - message types.LarkMessage +func (_e *MockLarkCache_Expecter) PushMessage(ctx interface{}, message interface{}) *MockLarkCache_PushMessage_Call { + return &MockLarkCache_PushMessage_Call{Call: _e.mock.On("PushMessage", ctx, message)} +} + +func (_c *MockLarkCache_PushMessage_Call) Run(run func(ctx context.Context, message types.LarkMessage)) *MockLarkCache_PushMessage_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(types.LarkMessage)) + }) + return _c +} + +func (_c *MockLarkCache_PushMessage_Call) Return(_a0 error) *MockLarkCache_PushMessage_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockLarkCache_PushMessage_Call) RunAndReturn(run func(context.Context, types.LarkMessage) error) *MockLarkCache_PushMessage_Call { + _c.Call.Return(run) + return _c +} + +// SetChatIDs provides a mock function with given fields: ctx, appID, chatIDs, expiration +func (_m *MockLarkCache) SetChatIDs(ctx context.Context, appID string, chatIDs []string, expiration time.Duration) error { + ret := _m.Called(ctx, appID, chatIDs, expiration) + + if len(ret) == 0 { + panic("no return value specified for SetChatIDs") + } + + var r0 error + if rf, ok := ret.Get(0).(func(context.Context, string, []string, time.Duration) error); ok { + r0 = rf(ctx, appID, chatIDs, expiration) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// MockLarkCache_SetChatIDs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SetChatIDs' +type MockLarkCache_SetChatIDs_Call struct { + *mock.Call +} + +// SetChatIDs is a helper method to define mock.On call +// - ctx context.Context +// - appID string +// - chatIDs []string +// - expiration time.Duration +func (_e *MockLarkCache_Expecter) SetChatIDs(ctx interface{}, appID interface{}, chatIDs interface{}, expiration interface{}) *MockLarkCache_SetChatIDs_Call { + return &MockLarkCache_SetChatIDs_Call{Call: _e.mock.On("SetChatIDs", ctx, appID, chatIDs, expiration)} +} + +func (_c *MockLarkCache_SetChatIDs_Call) Run(run func(ctx context.Context, appID string, chatIDs []string, expiration time.Duration)) *MockLarkCache_SetChatIDs_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].([]string), args[3].(time.Duration)) + }) + return _c +} + +func (_c *MockLarkCache_SetChatIDs_Call) Return(_a0 error) *MockLarkCache_SetChatIDs_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockLarkCache_SetChatIDs_Call) RunAndReturn(run func(context.Context, string, []string, time.Duration) error) *MockLarkCache_SetChatIDs_Call { + _c.Call.Return(run) + return _c +} + +// NewMockLarkCache creates a new instance of MockLarkCache. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockLarkCache(t interface { + mock.TestingT + Cleanup(func()) +}) *MockLarkCache { + mock := &MockLarkCache{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/_mocks/opencsg.com/csghub-server/notification/notifychannel/channel/lark/client/mock_LarkService.go b/_mocks/opencsg.com/csghub-server/notification/notifychannel/channel/lark/client/mock_LarkService.go new file mode 100644 index 000000000..af0e34972 --- /dev/null +++ b/_mocks/opencsg.com/csghub-server/notification/notifychannel/channel/lark/client/mock_LarkService.go @@ -0,0 +1,491 @@ +// Code generated by mockery v2.53.5. DO NOT EDIT. + +package client + +import ( + cache "opencsg.com/csghub-server/notification/notifychannel/channel/lark/cache" + + context "context" + + mock "github.com/stretchr/testify/mock" +) + +// MockLarkService is an autogenerated mock type for the LarkService type +type MockLarkService struct { + mock.Mock +} + +type MockLarkService_Expecter struct { + mock *mock.Mock +} + +func (_m *MockLarkService) EXPECT() *MockLarkService_Expecter { + return &MockLarkService_Expecter{mock: &_m.Mock} +} + +// GetAppID provides a mock function with no fields +func (_m *MockLarkService) GetAppID() string { + ret := _m.Called() + + if len(ret) == 0 { + panic("no return value specified for GetAppID") + } + + var r0 string + if rf, ok := ret.Get(0).(func() string); ok { + r0 = rf() + } else { + r0 = ret.Get(0).(string) + } + + return r0 +} + +// MockLarkService_GetAppID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetAppID' +type MockLarkService_GetAppID_Call struct { + *mock.Call +} + +// GetAppID is a helper method to define mock.On call +func (_e *MockLarkService_Expecter) GetAppID() *MockLarkService_GetAppID_Call { + return &MockLarkService_GetAppID_Call{Call: _e.mock.On("GetAppID")} +} + +func (_c *MockLarkService_GetAppID_Call) Run(run func()) *MockLarkService_GetAppID_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *MockLarkService_GetAppID_Call) Return(_a0 string) *MockLarkService_GetAppID_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *MockLarkService_GetAppID_Call) RunAndReturn(run func() string) *MockLarkService_GetAppID_Call { + _c.Call.Return(run) + return _c +} + +// GetChatIDs provides a mock function with given fields: ctx +func (_m *MockLarkService) GetChatIDs(ctx context.Context) ([]string, error) { + ret := _m.Called(ctx) + + if len(ret) == 0 { + panic("no return value specified for GetChatIDs") + } + + var r0 []string + var r1 error + if rf, ok := ret.Get(0).(func(context.Context) ([]string, error)); ok { + return rf(ctx) + } + if rf, ok := ret.Get(0).(func(context.Context) []string); ok { + r0 = rf(ctx) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]string) + } + } + + if rf, ok := ret.Get(1).(func(context.Context) error); ok { + r1 = rf(ctx) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockLarkService_GetChatIDs_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetChatIDs' +type MockLarkService_GetChatIDs_Call struct { + *mock.Call +} + +// GetChatIDs is a helper method to define mock.On call +// - ctx context.Context +func (_e *MockLarkService_Expecter) GetChatIDs(ctx interface{}) *MockLarkService_GetChatIDs_Call { + return &MockLarkService_GetChatIDs_Call{Call: _e.mock.On("GetChatIDs", ctx)} +} + +func (_c *MockLarkService_GetChatIDs_Call) Run(run func(ctx context.Context)) *MockLarkService_GetChatIDs_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context)) + }) + return _c +} + +func (_c *MockLarkService_GetChatIDs_Call) Return(chatIDs []string, err error) *MockLarkService_GetChatIDs_Call { + _c.Call.Return(chatIDs, err) + return _c +} + +func (_c *MockLarkService_GetChatIDs_Call) RunAndReturn(run func(context.Context) ([]string, error)) *MockLarkService_GetChatIDs_Call { + _c.Call.Return(run) + return _c +} + +// GetChatIDsWithCache provides a mock function with given fields: ctx, _a1 +func (_m *MockLarkService) GetChatIDsWithCache(ctx context.Context, _a1 cache.LarkCache) ([]string, error) { + ret := _m.Called(ctx, _a1) + + if len(ret) == 0 { + panic("no return value specified for GetChatIDsWithCache") + } + + var r0 []string + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, cache.LarkCache) ([]string, error)); ok { + return rf(ctx, _a1) + } + if rf, ok := ret.Get(0).(func(context.Context, cache.LarkCache) []string); ok { + r0 = rf(ctx, _a1) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]string) + } + } + + if rf, ok := ret.Get(1).(func(context.Context, cache.LarkCache) error); ok { + r1 = rf(ctx, _a1) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockLarkService_GetChatIDsWithCache_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetChatIDsWithCache' +type MockLarkService_GetChatIDsWithCache_Call struct { + *mock.Call +} + +// GetChatIDsWithCache is a helper method to define mock.On call +// - ctx context.Context +// - _a1 cache.LarkCache +func (_e *MockLarkService_Expecter) GetChatIDsWithCache(ctx interface{}, _a1 interface{}) *MockLarkService_GetChatIDsWithCache_Call { + return &MockLarkService_GetChatIDsWithCache_Call{Call: _e.mock.On("GetChatIDsWithCache", ctx, _a1)} +} + +func (_c *MockLarkService_GetChatIDsWithCache_Call) Run(run func(ctx context.Context, _a1 cache.LarkCache)) *MockLarkService_GetChatIDsWithCache_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(cache.LarkCache)) + }) + return _c +} + +func (_c *MockLarkService_GetChatIDsWithCache_Call) Return(chatIDs []string, err error) *MockLarkService_GetChatIDsWithCache_Call { + _c.Call.Return(chatIDs, err) + return _c +} + +func (_c *MockLarkService_GetChatIDsWithCache_Call) RunAndReturn(run func(context.Context, cache.LarkCache) ([]string, error)) *MockLarkService_GetChatIDsWithCache_Call { + _c.Call.Return(run) + return _c +} + +// GetUserIDByMobile provides a mock function with given fields: ctx, mobile +func (_m *MockLarkService) GetUserIDByMobile(ctx context.Context, mobile string) (string, error) { + ret := _m.Called(ctx, mobile) + + if len(ret) == 0 { + panic("no return value specified for GetUserIDByMobile") + } + + var r0 string + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (string, error)); ok { + return rf(ctx, mobile) + } + if rf, ok := ret.Get(0).(func(context.Context, string) string); ok { + r0 = rf(ctx, mobile) + } else { + r0 = ret.Get(0).(string) + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, mobile) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockLarkService_GetUserIDByMobile_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetUserIDByMobile' +type MockLarkService_GetUserIDByMobile_Call struct { + *mock.Call +} + +// GetUserIDByMobile is a helper method to define mock.On call +// - ctx context.Context +// - mobile string +func (_e *MockLarkService_Expecter) GetUserIDByMobile(ctx interface{}, mobile interface{}) *MockLarkService_GetUserIDByMobile_Call { + return &MockLarkService_GetUserIDByMobile_Call{Call: _e.mock.On("GetUserIDByMobile", ctx, mobile)} +} + +func (_c *MockLarkService_GetUserIDByMobile_Call) Run(run func(ctx context.Context, mobile string)) *MockLarkService_GetUserIDByMobile_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockLarkService_GetUserIDByMobile_Call) Return(_a0 string, _a1 error) *MockLarkService_GetUserIDByMobile_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockLarkService_GetUserIDByMobile_Call) RunAndReturn(run func(context.Context, string) (string, error)) *MockLarkService_GetUserIDByMobile_Call { + _c.Call.Return(run) + return _c +} + +// IsInChat provides a mock function with given fields: ctx, chatID +func (_m *MockLarkService) IsInChat(ctx context.Context, chatID string) (bool, error) { + ret := _m.Called(ctx, chatID) + + if len(ret) == 0 { + panic("no return value specified for IsInChat") + } + + var r0 bool + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string) (bool, error)); ok { + return rf(ctx, chatID) + } + if rf, ok := ret.Get(0).(func(context.Context, string) bool); ok { + r0 = rf(ctx, chatID) + } else { + r0 = ret.Get(0).(bool) + } + + if rf, ok := ret.Get(1).(func(context.Context, string) error); ok { + r1 = rf(ctx, chatID) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockLarkService_IsInChat_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'IsInChat' +type MockLarkService_IsInChat_Call struct { + *mock.Call +} + +// IsInChat is a helper method to define mock.On call +// - ctx context.Context +// - chatID string +func (_e *MockLarkService_Expecter) IsInChat(ctx interface{}, chatID interface{}) *MockLarkService_IsInChat_Call { + return &MockLarkService_IsInChat_Call{Call: _e.mock.On("IsInChat", ctx, chatID)} +} + +func (_c *MockLarkService_IsInChat_Call) Run(run func(ctx context.Context, chatID string)) *MockLarkService_IsInChat_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string)) + }) + return _c +} + +func (_c *MockLarkService_IsInChat_Call) Return(_a0 bool, _a1 error) *MockLarkService_IsInChat_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockLarkService_IsInChat_Call) RunAndReturn(run func(context.Context, string) (bool, error)) *MockLarkService_IsInChat_Call { + _c.Call.Return(run) + return _c +} + +// ReplyMessage provides a mock function with given fields: ctx, messageID, msgType, content +func (_m *MockLarkService) ReplyMessage(ctx context.Context, messageID string, msgType string, content string) (string, error) { + ret := _m.Called(ctx, messageID, msgType, content) + + if len(ret) == 0 { + panic("no return value specified for ReplyMessage") + } + + var r0 string + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (string, error)); ok { + return rf(ctx, messageID, msgType, content) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) string); ok { + r0 = rf(ctx, messageID, msgType, content) + } else { + r0 = ret.Get(0).(string) + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { + r1 = rf(ctx, messageID, msgType, content) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockLarkService_ReplyMessage_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ReplyMessage' +type MockLarkService_ReplyMessage_Call struct { + *mock.Call +} + +// ReplyMessage is a helper method to define mock.On call +// - ctx context.Context +// - messageID string +// - msgType string +// - content string +func (_e *MockLarkService_Expecter) ReplyMessage(ctx interface{}, messageID interface{}, msgType interface{}, content interface{}) *MockLarkService_ReplyMessage_Call { + return &MockLarkService_ReplyMessage_Call{Call: _e.mock.On("ReplyMessage", ctx, messageID, msgType, content)} +} + +func (_c *MockLarkService_ReplyMessage_Call) Run(run func(ctx context.Context, messageID string, msgType string, content string)) *MockLarkService_ReplyMessage_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) + }) + return _c +} + +func (_c *MockLarkService_ReplyMessage_Call) Return(_a0 string, _a1 error) *MockLarkService_ReplyMessage_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockLarkService_ReplyMessage_Call) RunAndReturn(run func(context.Context, string, string, string) (string, error)) *MockLarkService_ReplyMessage_Call { + _c.Call.Return(run) + return _c +} + +// SendChatMessage provides a mock function with given fields: ctx, chatID, msgType, content +func (_m *MockLarkService) SendChatMessage(ctx context.Context, chatID string, msgType string, content string) (string, error) { + ret := _m.Called(ctx, chatID, msgType, content) + + if len(ret) == 0 { + panic("no return value specified for SendChatMessage") + } + + var r0 string + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (string, error)); ok { + return rf(ctx, chatID, msgType, content) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) string); ok { + r0 = rf(ctx, chatID, msgType, content) + } else { + r0 = ret.Get(0).(string) + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { + r1 = rf(ctx, chatID, msgType, content) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockLarkService_SendChatMessage_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SendChatMessage' +type MockLarkService_SendChatMessage_Call struct { + *mock.Call +} + +// SendChatMessage is a helper method to define mock.On call +// - ctx context.Context +// - chatID string +// - msgType string +// - content string +func (_e *MockLarkService_Expecter) SendChatMessage(ctx interface{}, chatID interface{}, msgType interface{}, content interface{}) *MockLarkService_SendChatMessage_Call { + return &MockLarkService_SendChatMessage_Call{Call: _e.mock.On("SendChatMessage", ctx, chatID, msgType, content)} +} + +func (_c *MockLarkService_SendChatMessage_Call) Run(run func(ctx context.Context, chatID string, msgType string, content string)) *MockLarkService_SendChatMessage_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) + }) + return _c +} + +func (_c *MockLarkService_SendChatMessage_Call) Return(_a0 string, _a1 error) *MockLarkService_SendChatMessage_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockLarkService_SendChatMessage_Call) RunAndReturn(run func(context.Context, string, string, string) (string, error)) *MockLarkService_SendChatMessage_Call { + _c.Call.Return(run) + return _c +} + +// SendUserMessage provides a mock function with given fields: ctx, openID, msgType, content +func (_m *MockLarkService) SendUserMessage(ctx context.Context, openID string, msgType string, content string) (string, error) { + ret := _m.Called(ctx, openID, msgType, content) + + if len(ret) == 0 { + panic("no return value specified for SendUserMessage") + } + + var r0 string + var r1 error + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) (string, error)); ok { + return rf(ctx, openID, msgType, content) + } + if rf, ok := ret.Get(0).(func(context.Context, string, string, string) string); ok { + r0 = rf(ctx, openID, msgType, content) + } else { + r0 = ret.Get(0).(string) + } + + if rf, ok := ret.Get(1).(func(context.Context, string, string, string) error); ok { + r1 = rf(ctx, openID, msgType, content) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// MockLarkService_SendUserMessage_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'SendUserMessage' +type MockLarkService_SendUserMessage_Call struct { + *mock.Call +} + +// SendUserMessage is a helper method to define mock.On call +// - ctx context.Context +// - openID string +// - msgType string +// - content string +func (_e *MockLarkService_Expecter) SendUserMessage(ctx interface{}, openID interface{}, msgType interface{}, content interface{}) *MockLarkService_SendUserMessage_Call { + return &MockLarkService_SendUserMessage_Call{Call: _e.mock.On("SendUserMessage", ctx, openID, msgType, content)} +} + +func (_c *MockLarkService_SendUserMessage_Call) Run(run func(ctx context.Context, openID string, msgType string, content string)) *MockLarkService_SendUserMessage_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(context.Context), args[1].(string), args[2].(string), args[3].(string)) + }) + return _c +} + +func (_c *MockLarkService_SendUserMessage_Call) Return(_a0 string, _a1 error) *MockLarkService_SendUserMessage_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *MockLarkService_SendUserMessage_Call) RunAndReturn(run func(context.Context, string, string, string) (string, error)) *MockLarkService_SendUserMessage_Call { + _c.Call.Return(run) + return _c +} + +// NewMockLarkService creates a new instance of MockLarkService. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewMockLarkService(t interface { + mock.TestingT + Cleanup(func()) +}) *MockLarkService { + mock := &MockLarkService{} + mock.Mock.Test(t) + + t.Cleanup(func() { mock.AssertExpectations(t) }) + + return mock +} diff --git a/_mocks/opencsg.com/csghub-server/user/component/mock_UserPhoneComponent.go b/_mocks/opencsg.com/csghub-server/user/component/mock_UserPhoneComponent.go index def7e4905..7008b6ca9 100644 --- a/_mocks/opencsg.com/csghub-server/user/component/mock_UserPhoneComponent.go +++ b/_mocks/opencsg.com/csghub-server/user/component/mock_UserPhoneComponent.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.53.0. DO NOT EDIT. +// Code generated by mockery v2.53.5. DO NOT EDIT. package component diff --git a/api/router/api.go b/api/router/api.go index 0a3b5eadc..9903c7b38 100644 --- a/api/router/api.go +++ b/api/router/api.go @@ -514,7 +514,7 @@ func NewRouter(config *config.Config, enableSwagger bool) (*gin.Engine, error) { } createCSGBotRoutes(apiGroup, csgbotHandler) - err = createAdvancedRoutes(apiGroup, middlewareCollection, config) + err = createAdvancedRoutes(apiGroup, adminGroup, middlewareCollection, config) if err != nil { return nil, fmt.Errorf("error creating advance routes:%w", err) } diff --git a/api/router/api_ce.go b/api/router/api_ce.go index 5729a2cb1..7ecd412d3 100644 --- a/api/router/api_ce.go +++ b/api/router/api_ce.go @@ -14,7 +14,7 @@ import ( func useAdvancedMiddleware(r *gin.Engine, config *config.Config) {} -func createAdvancedRoutes(apiGroup *gin.RouterGroup, middlewareCollection middleware.MiddlewareCollection, config *config.Config) error { +func createAdvancedRoutes(apiGroup *gin.RouterGroup, adminGroup *gin.RouterGroup, middlewareCollection middleware.MiddlewareCollection, config *config.Config) error { repoHandler, err := handler.NewRepoHandler(config) if err != nil { return fmt.Errorf("failed to create repo handler: %w", err) diff --git a/builder/store/database/agent_config.go b/builder/store/database/agent_config.go new file mode 100644 index 000000000..d4cdc9848 --- /dev/null +++ b/builder/store/database/agent_config.go @@ -0,0 +1,140 @@ +package database + +import ( + "context" + "database/sql" + "errors" + "fmt" + + "opencsg.com/csghub-server/common/errorx" +) + +type agentConfigStoreImpl struct { + db *DB +} + +type AgentConfigStore interface { + GetByName(ctx context.Context, name string) (*AgentConfig, error) + GetByID(ctx context.Context, id int64) (*AgentConfig, error) + List(ctx context.Context) ([]*AgentConfig, error) + Update(ctx context.Context, config *AgentConfig) error + Create(ctx context.Context, config *AgentConfig) error + Delete(ctx context.Context, id int64) error + GetConfigValue(ctx context.Context, name string, key string) (any, error) +} + +func NewAgentConfigStore() AgentConfigStore { + return &agentConfigStoreImpl{ + db: defaultDB, + } +} + +func NewAgentConfigStoreWithDB(db *DB) AgentConfigStore { + return &agentConfigStoreImpl{ + db: db, + } +} + +type AgentConfig struct { + ID int64 `bun:",pk,autoincrement" json:"id"` + Name string `bun:",notnull,unique" json:"name"` + Config map[string]any `bun:",type:jsonb,notnull" json:"config"` + times +} + +func (s *agentConfigStoreImpl) GetByName(ctx context.Context, name string) (*AgentConfig, error) { + var config AgentConfig + err := s.db.Operator.Core.NewSelect(). + Model(&config). + Where("name = ?", name). + Scan(ctx) + if err != nil { + if errors.Is(err, sql.ErrNoRows) { + return nil, nil + } + return nil, errorx.HandleDBError(err, map[string]any{"operation": "get_agent_config_by_name", "name": name}) + } + return &config, nil +} + +func (s *agentConfigStoreImpl) GetByID(ctx context.Context, id int64) (*AgentConfig, error) { + config := AgentConfig{ID: id} + err := s.db.Operator.Core.NewSelect(). + Model(&config). + WherePK(). + Scan(ctx) + if err != nil { + if errors.Is(err, sql.ErrNoRows) { + return nil, nil + } + return nil, errorx.HandleDBError(err, map[string]any{"operation": "get_agent_config_by_id", "id": id}) + } + return &config, nil +} + +func (s *agentConfigStoreImpl) List(ctx context.Context) ([]*AgentConfig, error) { + var configs []*AgentConfig + err := s.db.Operator.Core.NewSelect(). + Model(&configs). + Order("updated_at DESC"). + Scan(ctx) + if err != nil { + return nil, errorx.HandleDBError(err, map[string]any{"operation": "list_agent_configs"}) + } + return configs, nil +} + +func (s *agentConfigStoreImpl) Update(ctx context.Context, config *AgentConfig) error { + res, err := s.db.Operator.Core.NewUpdate(). + Model(config). + Where("id = ?", config.ID). + Exec(ctx) + if err != nil { + return errorx.HandleDBError(err, map[string]any{"operation": "update_agent_config"}) + } + if err := assertAffectedOneRow(res, err); err != nil { + return errorx.HandleDBError(err, map[string]any{"operation": "update_agent_config"}) + } + return nil +} + +func (s *agentConfigStoreImpl) Create(ctx context.Context, config *AgentConfig) error { + res, err := s.db.Operator.Core.NewInsert(). + Model(config). + Exec(ctx) + if err != nil { + return fmt.Errorf("failed to create agent config: %w", err) + } + if err := assertAffectedOneRow(res, err); err != nil { + return fmt.Errorf("failed to create agent config: %w", err) + } + return nil +} + +func (s *agentConfigStoreImpl) Delete(ctx context.Context, id int64) error { + res, err := s.db.Operator.Core.NewDelete(). + Model((*AgentConfig)(nil)). + Where("id = ?", id). + Exec(ctx) + if err != nil { + return errorx.HandleDBError(err, map[string]any{"operation": "delete_agent_config", "id": id}) + } + return assertAffectedOneRow(res, err) +} + +func (s *agentConfigStoreImpl) GetConfigValue(ctx context.Context, name string, key string) (any, error) { + config, err := s.GetByName(ctx, name) + if err != nil { + return nil, fmt.Errorf("failed to get agent config: %w", err) + } + if config == nil { + return nil, fmt.Errorf("agent config not found") + } + + value, ok := config.Config[key] + if !ok { + return nil, fmt.Errorf("config key %s not found", key) + } + + return value, nil +} diff --git a/builder/store/database/agent_config_test.go b/builder/store/database/agent_config_test.go new file mode 100644 index 000000000..1cbffdc33 --- /dev/null +++ b/builder/store/database/agent_config_test.go @@ -0,0 +1,599 @@ +package database_test + +import ( + "context" + "testing" + "time" + + "github.com/stretchr/testify/require" + "opencsg.com/csghub-server/builder/store/database" + "opencsg.com/csghub-server/common/tests" +) + +func TestAgentConfigStore_Get(t *testing.T) { + db := tests.InitTestDB() + defer db.Close() + ctx := context.TODO() + + store := database.NewAgentConfigStoreWithDB(db) + + t.Run("success - get existing config", func(t *testing.T) { + // Get existing config (from migration) and update it + existingConfig, err := store.GetByName(ctx, "instance") + require.NoError(t, err) + require.NotNil(t, existingConfig) + + // Update with test values + existingConfig.Config = map[string]any{ + "code_instance_quota_per_user": 5, + "langflow_instance_quota_per_user": 10, + } + err = store.Update(ctx, existingConfig) + require.NoError(t, err) + + // Get the config + retrievedConfig, err := store.GetByName(ctx, "instance") + require.NoError(t, err) + require.NotNil(t, retrievedConfig) + require.Equal(t, existingConfig.ID, retrievedConfig.ID) + require.Equal(t, 5, int(retrievedConfig.Config["code_instance_quota_per_user"].(float64))) + require.Equal(t, 10, int(retrievedConfig.Config["langflow_instance_quota_per_user"].(float64))) + }) + +} + +func TestAgentConfigStore_Create(t *testing.T) { + db := tests.InitTestDB() + defer db.Close() + ctx := context.TODO() + + store := database.NewAgentConfigStoreWithDB(db) + + t.Run("success", func(t *testing.T) { + config := &database.AgentConfig{ + Name: "test-config-1", + Config: map[string]any{ + "code_instance_quota_per_user": 5, + "langflow_instance_quota_per_user": 10, + "custom_setting": "value", + }, + } + + err := store.Create(ctx, config) + require.NoError(t, err) + require.NotZero(t, config.ID) + require.NotZero(t, config.CreatedAt) + require.NotZero(t, config.UpdatedAt) + }) + + t.Run("create with empty config", func(t *testing.T) { + config := &database.AgentConfig{ + Name: "test-config-2", + Config: map[string]any{}, + } + + err := store.Create(ctx, config) + require.NoError(t, err) + require.NotZero(t, config.ID) + }) +} + +func TestAgentConfigStore_Update(t *testing.T) { + db := tests.InitTestDB() + defer db.Close() + ctx := context.TODO() + + store := database.NewAgentConfigStoreWithDB(db) + + t.Run("success", func(t *testing.T) { + // Get existing config (from migration) + config, err := store.GetByName(ctx, "instance") + require.NoError(t, err) + require.NotNil(t, config) + originalUpdatedAt := config.UpdatedAt + + // Wait a bit to ensure UpdatedAt changes + time.Sleep(10 * time.Millisecond) + + // Update config + config.Config = map[string]any{ + "code_instance_quota_per_user": 15, + "langflow_instance_quota_per_user": 20, + "new_setting": "new_value", + } + err = store.Update(ctx, config) + require.NoError(t, err) + + // Verify update + updatedConfig, err := store.GetByName(ctx, "instance") + require.NoError(t, err) + require.NotNil(t, updatedConfig) + require.Equal(t, 15, int(updatedConfig.Config["code_instance_quota_per_user"].(float64))) + require.Equal(t, 20, int(updatedConfig.Config["langflow_instance_quota_per_user"].(float64))) + require.Equal(t, "new_value", updatedConfig.Config["new_setting"]) + require.True(t, updatedConfig.UpdatedAt.After(originalUpdatedAt)) + }) + + t.Run("update non-existent config", func(t *testing.T) { + config := &database.AgentConfig{ + ID: 99999, + Config: map[string]any{ + "code_instance_quota_per_user": 5, + }, + } + + err := store.Update(ctx, config) + require.Error(t, err) + }) +} + +func TestAgentConfigStore_GetConfigValue(t *testing.T) { + db := tests.InitTestDB() + defer db.Close() + ctx := context.TODO() + + store := database.NewAgentConfigStoreWithDB(db) + + t.Run("success", func(t *testing.T) { + // Get existing config and update it + config, err := store.GetByName(ctx, "instance") + require.NoError(t, err) + require.NotNil(t, config) + + config.Config = map[string]any{ + "code_instance_quota_per_user": 5, + "langflow_instance_quota_per_user": 10, + "string_setting": "test_value", + "bool_setting": true, + } + err = store.Update(ctx, config) + require.NoError(t, err) + + // Get specific values + codeQuota, err := store.GetConfigValue(ctx, "instance", "code_instance_quota_per_user") + require.NoError(t, err) + require.Equal(t, float64(5), codeQuota) + + langflowQuota, err := store.GetConfigValue(ctx, "instance", "langflow_instance_quota_per_user") + require.NoError(t, err) + require.Equal(t, float64(10), langflowQuota) + + stringValue, err := store.GetConfigValue(ctx, "instance", "string_setting") + require.NoError(t, err) + require.Equal(t, "test_value", stringValue) + + boolValue, err := store.GetConfigValue(ctx, "instance", "bool_setting") + require.NoError(t, err) + require.Equal(t, true, boolValue) + }) + + t.Run("key not found", func(t *testing.T) { + // Get existing config and update it + config, err := store.GetByName(ctx, "instance") + require.NoError(t, err) + require.NotNil(t, config) + + config.Config = map[string]any{ + "code_instance_quota_per_user": 5, + } + err = store.Update(ctx, config) + require.NoError(t, err) + + // Try to get non-existent key + _, err = store.GetConfigValue(ctx, "instance", "non_existent_key") + require.Error(t, err) + require.Contains(t, err.Error(), "config key non_existent_key not found") + }) + + t.Run("config not found", func(t *testing.T) { + // Note: This test may not work as expected because the migration inserts a default config + // The agent_config table is designed to always have one row + // GetConfigValue will return an error for a non-existent key, not for missing config + _, err := store.GetConfigValue(ctx, "instance", "non_existent_key_for_test") + require.Error(t, err) + require.Contains(t, err.Error(), "config key non_existent_key_for_test not found") + }) +} + +func TestAgentConfigStore_CRUD(t *testing.T) { + db := tests.InitTestDB() + defer db.Close() + ctx := context.TODO() + + store := database.NewAgentConfigStoreWithDB(db) + + // Read existing config (from migration) + config, err := store.GetByName(ctx, "instance") + require.NoError(t, err) + require.NotNil(t, config) + require.NotZero(t, config.ID) + + // Update + config.Config = map[string]any{ + "code_instance_quota_per_user": 15, + "langflow_instance_quota_per_user": 10, + } + err = store.Update(ctx, config) + require.NoError(t, err) + + // Verify update + updatedConfig, err := store.GetByName(ctx, "instance") + require.NoError(t, err) + require.Equal(t, 15, int(updatedConfig.Config["code_instance_quota_per_user"].(float64))) +} + +func TestAgentConfigStore_ComplexConfigStructure(t *testing.T) { + db := tests.InitTestDB() + defer db.Close() + ctx := context.TODO() + + store := database.NewAgentConfigStoreWithDB(db) + + t.Run("create and retrieve complex nested config", func(t *testing.T) { + // Get existing config and update it with complex nested structure + complexConfig, err := store.GetByName(ctx, "instance") + require.NoError(t, err) + require.NotNil(t, complexConfig) + + complexConfig.Config = map[string]any{ + "code_instance_quota_per_user": 5, + "langflow_instance_quota_per_user": 10, + "quota_settings": map[string]any{ + "default": 5, + "premium": 20, + "enterprise": map[string]any{ + "max_instances": 100, + "features": []any{"feature1", "feature2", "feature3"}, + }, + }, + "instance_types": []any{ + map[string]any{ + "type": "code", + "quota": 5, + "enabled": true, + "metadata": map[string]any{"cpu": "2", "memory": "4GB"}, + }, + map[string]any{ + "type": "langflow", + "quota": 10, + "enabled": true, + "metadata": map[string]any{"cpu": "4", "memory": "8GB"}, + }, + }, + "feature_flags": map[string]any{ + "enable_auto_scaling": true, + "enable_monitoring": false, + "beta_features": []any{"feature_a", "feature_b"}, + }, + "limits": map[string]any{ + "max_concurrent": 50, + "rate_limits": map[string]any{ + "per_minute": 100, + "per_hour": 1000, + }, + }, + } + + err = store.Update(ctx, complexConfig) + require.NoError(t, err) + require.NotZero(t, complexConfig.ID) + + // Retrieve and verify complex structure + retrievedConfig, err := store.GetByName(ctx, "instance") + require.NoError(t, err) + require.NotNil(t, retrievedConfig) + + // Verify top-level simple values + require.Equal(t, 5, int(retrievedConfig.Config["code_instance_quota_per_user"].(float64))) + require.Equal(t, 10, int(retrievedConfig.Config["langflow_instance_quota_per_user"].(float64))) + + // Verify nested map structure + quotaSettings, ok := retrievedConfig.Config["quota_settings"].(map[string]any) + require.True(t, ok, "quota_settings should be a map") + require.Equal(t, float64(5), quotaSettings["default"]) + require.Equal(t, float64(20), quotaSettings["premium"]) + + enterprise, ok := quotaSettings["enterprise"].(map[string]any) + require.True(t, ok, "enterprise should be a map") + require.Equal(t, float64(100), enterprise["max_instances"]) + + features, ok := enterprise["features"].([]any) + require.True(t, ok, "features should be an array") + require.Len(t, features, 3) + require.Equal(t, "feature1", features[0]) + require.Equal(t, "feature2", features[1]) + require.Equal(t, "feature3", features[2]) + + // Verify array of maps + instanceTypes, ok := retrievedConfig.Config["instance_types"].([]any) + require.True(t, ok, "instance_types should be an array") + require.Len(t, instanceTypes, 2) + + codeType, ok := instanceTypes[0].(map[string]any) + require.True(t, ok, "first instance type should be a map") + require.Equal(t, "code", codeType["type"]) + require.Equal(t, float64(5), codeType["quota"]) + require.Equal(t, true, codeType["enabled"]) + + codeMetadata, ok := codeType["metadata"].(map[string]any) + require.True(t, ok, "code metadata should be a map") + require.Equal(t, "2", codeMetadata["cpu"]) + require.Equal(t, "4GB", codeMetadata["memory"]) + + langflowType, ok := instanceTypes[1].(map[string]any) + require.True(t, ok, "second instance type should be a map") + require.Equal(t, "langflow", langflowType["type"]) + require.Equal(t, float64(10), langflowType["quota"]) + + // Verify feature flags + featureFlags, ok := retrievedConfig.Config["feature_flags"].(map[string]any) + require.True(t, ok, "feature_flags should be a map") + require.Equal(t, true, featureFlags["enable_auto_scaling"]) + require.Equal(t, false, featureFlags["enable_monitoring"]) + + betaFeatures, ok := featureFlags["beta_features"].([]any) + require.True(t, ok, "beta_features should be an array") + require.Len(t, betaFeatures, 2) + require.Equal(t, "feature_a", betaFeatures[0]) + require.Equal(t, "feature_b", betaFeatures[1]) + + // Verify nested limits + limits, ok := retrievedConfig.Config["limits"].(map[string]any) + require.True(t, ok, "limits should be a map") + require.Equal(t, float64(50), limits["max_concurrent"]) + + rateLimits, ok := limits["rate_limits"].(map[string]any) + require.True(t, ok, "rate_limits should be a map") + require.Equal(t, float64(100), rateLimits["per_minute"]) + require.Equal(t, float64(1000), rateLimits["per_hour"]) + }) + + t.Run("update complex config structure", func(t *testing.T) { + // Get existing config and update it + initialConfig, err := store.GetByName(ctx, "instance") + require.NoError(t, err) + require.NotNil(t, initialConfig) + + initialConfig.Config = map[string]any{ + "simple_value": 42, + "nested": map[string]any{ + "level1": map[string]any{ + "level2": "value", + }, + }, + } + err = store.Update(ctx, initialConfig) + require.NoError(t, err) + + // Update with more complex structure + updatedConfig := map[string]any{ + "simple_value": 100, + "nested": map[string]any{ + "level1": map[string]any{ + "level2": "updated_value", + "level2_new": map[string]any{ + "deep_nested": []any{1, 2, 3}, + }, + }, + }, + "new_section": map[string]any{ + "array_of_objects": []any{ + map[string]any{"id": 1, "name": "item1"}, + map[string]any{"id": 2, "name": "item2"}, + }, + "mixed_types": map[string]any{ + "string": "text", + "number": 42.5, + "boolean": true, + "null": nil, + }, + }, + } + + initialConfig.Config = updatedConfig + err = store.Update(ctx, initialConfig) + require.NoError(t, err) + + // Verify updated structure + retrievedConfig, err := store.GetByName(ctx, "instance") + require.NoError(t, err) + require.Equal(t, float64(100), retrievedConfig.Config["simple_value"]) + + nested, ok := retrievedConfig.Config["nested"].(map[string]any) + require.True(t, ok) + level1, ok := nested["level1"].(map[string]any) + require.True(t, ok) + require.Equal(t, "updated_value", level1["level2"]) + + level2New, ok := level1["level2_new"].(map[string]any) + require.True(t, ok) + deepNested, ok := level2New["deep_nested"].([]any) + require.True(t, ok) + require.Len(t, deepNested, 3) + require.Equal(t, float64(1), deepNested[0]) + require.Equal(t, float64(2), deepNested[1]) + require.Equal(t, float64(3), deepNested[2]) + + newSection, ok := retrievedConfig.Config["new_section"].(map[string]any) + require.True(t, ok) + arrayOfObjects, ok := newSection["array_of_objects"].([]any) + require.True(t, ok) + require.Len(t, arrayOfObjects, 2) + + item1, ok := arrayOfObjects[0].(map[string]any) + require.True(t, ok) + require.Equal(t, float64(1), item1["id"]) + require.Equal(t, "item1", item1["name"]) + + mixedTypes, ok := newSection["mixed_types"].(map[string]any) + require.True(t, ok) + require.Equal(t, "text", mixedTypes["string"]) + require.Equal(t, 42.5, mixedTypes["number"]) + require.Equal(t, true, mixedTypes["boolean"]) + require.Nil(t, mixedTypes["null"]) + }) + + t.Run("get config value from complex structure", func(t *testing.T) { + // Get existing config and update it with complex structure + config, err := store.GetByName(ctx, "instance") + require.NoError(t, err) + require.NotNil(t, config) + + config.Config = map[string]any{ + "top_level": "value", + "nested": map[string]any{ + "key": "nested_value", + "deep": map[string]any{ + "deeper": map[string]any{ + "value": 123, + }, + }, + }, + } + err = store.Update(ctx, config) + require.NoError(t, err) + + // Get top-level value + topLevel, err := store.GetConfigValue(ctx, "instance", "top_level") + require.NoError(t, err) + require.Equal(t, "value", topLevel) + + // GetConfigValue only returns top-level keys, not nested paths + // So nested.key won't work - this is expected behavior + _, err = store.GetConfigValue(ctx, "instance", "nested") + require.NoError(t, err) // This should work as "nested" is a top-level key + + _, err = store.GetConfigValue(ctx, "instance", "nested.key") + require.Error(t, err) // This should fail as "nested.key" is not a top-level key + require.Contains(t, err.Error(), "config key nested.key not found") + }) +} + +func TestAgentConfigStore_GetByID(t *testing.T) { + db := tests.InitTestDB() + defer db.Close() + ctx := context.TODO() + + store := database.NewAgentConfigStoreWithDB(db) + + t.Run("success", func(t *testing.T) { + // Get existing config (from migration) + config, err := store.GetByName(ctx, "instance") + require.NoError(t, err) + require.NotNil(t, config) + require.NotZero(t, config.ID) + + // Get by ID + retrievedConfig, err := store.GetByID(ctx, config.ID) + require.NoError(t, err) + require.NotNil(t, retrievedConfig) + require.Equal(t, config.ID, retrievedConfig.ID) + require.Equal(t, config.Name, retrievedConfig.Name) + }) + + t.Run("non-existent id", func(t *testing.T) { + // Try to get a config that doesn't exist + retrievedConfig, err := store.GetByID(ctx, 99999) + require.NoError(t, err) + require.Nil(t, retrievedConfig) + }) +} + +func TestAgentConfigStore_List(t *testing.T) { + db := tests.InitTestDB() + defer db.Close() + ctx := context.TODO() + + store := database.NewAgentConfigStoreWithDB(db) + + t.Run("success", func(t *testing.T) { + // Create a few test configs + config1 := &database.AgentConfig{ + Name: "test-config-list-1", + Config: map[string]any{ + "setting1": "value1", + }, + } + err := store.Create(ctx, config1) + require.NoError(t, err) + + // Wait a bit to ensure different updated_at + time.Sleep(10 * time.Millisecond) + + config2 := &database.AgentConfig{ + Name: "test-config-list-2", + Config: map[string]any{ + "setting2": "value2", + }, + } + err = store.Create(ctx, config2) + require.NoError(t, err) + + // List all configs + configs, err := store.List(ctx) + require.NoError(t, err) + require.NotNil(t, configs) + require.GreaterOrEqual(t, len(configs), 2) // At least the two we created plus the default "instance" + + // Verify ordering (should be by updated_at DESC, so config2 should come before config1) + foundConfig1 := false + foundConfig2 := false + for _, cfg := range configs { + if cfg.ID == config1.ID { + foundConfig1 = true + } + if cfg.ID == config2.ID { + foundConfig2 = true + } + } + require.True(t, foundConfig1, "config1 should be in the list") + require.True(t, foundConfig2, "config2 should be in the list") + + // Clean up + _ = store.Delete(ctx, config1.ID) + _ = store.Delete(ctx, config2.ID) + }) +} + +func TestAgentConfigStore_Delete(t *testing.T) { + db := tests.InitTestDB() + defer db.Close() + ctx := context.TODO() + + store := database.NewAgentConfigStoreWithDB(db) + + t.Run("success", func(t *testing.T) { + // Create a test config to delete + config := &database.AgentConfig{ + Name: "test-config-to-delete", + Config: map[string]any{ + "code_instance_quota_per_user": 5, + }, + } + + err := store.Create(ctx, config) + require.NoError(t, err) + require.NotZero(t, config.ID) + + // Verify it exists + retrievedConfig, err := store.GetByID(ctx, config.ID) + require.NoError(t, err) + require.NotNil(t, retrievedConfig) + + // Delete the config + err = store.Delete(ctx, config.ID) + require.NoError(t, err) + + // Verify it's deleted + deletedConfig, err := store.GetByID(ctx, config.ID) + require.NoError(t, err) + require.Nil(t, deletedConfig) + }) + + t.Run("delete non-existent config", func(t *testing.T) { + // Try to delete a config that doesn't exist + err := store.Delete(ctx, 99999) + require.Error(t, err) + require.Contains(t, err.Error(), "affected 0 row(s), want 1") + }) +} diff --git a/builder/store/database/migrations/20251229210545_create_table_agent_config.go b/builder/store/database/migrations/20251229210545_create_table_agent_config.go new file mode 100644 index 000000000..60baf993e --- /dev/null +++ b/builder/store/database/migrations/20251229210545_create_table_agent_config.go @@ -0,0 +1,38 @@ +package migrations + +import ( + "context" + + "github.com/uptrace/bun" +) + +type AgentConfig struct { + ID int64 `bun:",pk,autoincrement" json:"id"` + Name string `bun:",notnull,unique" json:"name"` + Config map[string]any `bun:",type:jsonb,notnull" json:"config"` + times +} + +func init() { + Migrations.MustRegister(func(ctx context.Context, db *bun.DB) error { + err := createTables(ctx, db, AgentConfig{}) + if err != nil { + return err + } + + // Initialize with default values + defaultConfig := AgentConfig{ + Name: "instance", + Config: map[string]any{ + "code_instance_quota_per_user": 5, + "langflow_instance_quota_per_user": 10, + }, + } + _, err = db.NewInsert(). + Model(&defaultConfig). + Exec(ctx) + return err + }, func(ctx context.Context, db *bun.DB) error { + return dropTables(ctx, db, AgentConfig{}) + }) +} diff --git a/common/config/config.go b/common/config/config.go index 49eb383a0..f2b01291c 100644 --- a/common/config/config.go +++ b/common/config/config.go @@ -340,11 +340,9 @@ type Config struct { } Agent struct { - AutoHubServiceHost string `env:"OPENCSG_AGENT_AUTOHUB_SERVICE_HOST" default:"http://internal.opencsg-stg.com:8190"` - AgentHubServiceHost string `env:"OPENCSG_AGENT_AGENTHUB_SERVICE_HOST" default:""` - AgentHubServiceToken string `env:"OPENCSG_AGENT_AGENTHUB_SERVICE_TOKEN" default:""` - CodeInstanceQuotaPerUser int `env:"STARHUB_SERVER_AGENT_CODE_INSTANCE_QUOTA_PER_USER" default:"5"` - LangflowInstanceQuotaPerUser int `env:"STARHUB_SERVER_AGENT_LANGFLOW_INSTANCE_QUOTA_PER_USER" default:"5"` + AutoHubServiceHost string `env:"OPENCSG_AGENT_AUTOHUB_SERVICE_HOST" default:"http://internal.opencsg-stg.com:8190"` + AgentHubServiceHost string `env:"OPENCSG_AGENT_AGENTHUB_SERVICE_HOST" default:""` + AgentHubServiceToken string `env:"OPENCSG_AGENT_AGENTHUB_SERVICE_TOKEN" default:""` } DataViewer struct { diff --git a/common/types/agent.go b/common/types/agent.go index 3c2e4fc84..871cc129c 100644 --- a/common/types/agent.go +++ b/common/types/agent.go @@ -5,6 +5,27 @@ import ( "time" ) +// AgentConfig represents the agent system configuration +type AgentConfig struct { + ID int64 `json:"id"` + Name string `json:"name"` + Config map[string]any `json:"config"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` +} + +// CreateAgentConfigReq represents a request to create agent configuration +type CreateAgentConfigReq struct { + Name string `json:"name" binding:"required"` + Config map[string]any `json:"config" binding:"required"` +} + +// UpdateAgentConfigReq represents a request to update agent configuration +type UpdateAgentConfigReq struct { + Name *string `json:"name,omitempty"` + Config *map[string]any `json:"config,omitempty"` +} + // AgentTemplate represents the template for an agent type AgentTemplate struct { ID int64 `json:"id"` diff --git a/component/agent_config.go b/component/agent_config.go new file mode 100644 index 000000000..5177d2087 --- /dev/null +++ b/component/agent_config.go @@ -0,0 +1,144 @@ +package component + +import ( + "context" + "fmt" + + "opencsg.com/csghub-server/builder/store/database" + "opencsg.com/csghub-server/common/config" + "opencsg.com/csghub-server/common/types" +) + +type AgentConfigComponent interface { + GetByName(ctx context.Context, name string) (*types.AgentConfig, error) + GetByID(ctx context.Context, id int64) (*types.AgentConfig, error) + List(ctx context.Context) ([]*types.AgentConfig, error) + Create(ctx context.Context, req *types.CreateAgentConfigReq) (*types.AgentConfig, error) + Update(ctx context.Context, id int64, req *types.UpdateAgentConfigReq) (*types.AgentConfig, error) + Delete(ctx context.Context, id int64) error +} + +type agentConfigComponentImpl struct { + agentConfigStore database.AgentConfigStore +} + +func NewAgentConfigComponent(config *config.Config) (AgentConfigComponent, error) { + agentConfigStore := database.NewAgentConfigStore() + return &agentConfigComponentImpl{ + agentConfigStore: agentConfigStore, + }, nil +} + +func (c *agentConfigComponentImpl) GetByName(ctx context.Context, name string) (*types.AgentConfig, error) { + dbConfig, err := c.agentConfigStore.GetByName(ctx, name) + if err != nil { + return nil, fmt.Errorf("failed to get agent config by name: %w", err) + } + if dbConfig == nil { + return nil, fmt.Errorf("agent config not found") + } + + return &types.AgentConfig{ + ID: dbConfig.ID, + Name: dbConfig.Name, + Config: dbConfig.Config, + CreatedAt: dbConfig.CreatedAt, + UpdatedAt: dbConfig.UpdatedAt, + }, nil +} + +func (c *agentConfigComponentImpl) GetByID(ctx context.Context, id int64) (*types.AgentConfig, error) { + dbConfig, err := c.agentConfigStore.GetByID(ctx, id) + if err != nil { + return nil, fmt.Errorf("failed to get agent config by id: %w", err) + } + if dbConfig == nil { + return nil, fmt.Errorf("agent config not found") + } + + return &types.AgentConfig{ + ID: dbConfig.ID, + Name: dbConfig.Name, + Config: dbConfig.Config, + CreatedAt: dbConfig.CreatedAt, + UpdatedAt: dbConfig.UpdatedAt, + }, nil +} + +func (c *agentConfigComponentImpl) List(ctx context.Context) ([]*types.AgentConfig, error) { + dbConfigs, err := c.agentConfigStore.List(ctx) + if err != nil { + return nil, fmt.Errorf("failed to list agent configs: %w", err) + } + + configs := make([]*types.AgentConfig, len(dbConfigs)) + for i, dbConfig := range dbConfigs { + configs[i] = &types.AgentConfig{ + ID: dbConfig.ID, + Name: dbConfig.Name, + Config: dbConfig.Config, + CreatedAt: dbConfig.CreatedAt, + UpdatedAt: dbConfig.UpdatedAt, + } + } + + return configs, nil +} + +func (c *agentConfigComponentImpl) Create(ctx context.Context, req *types.CreateAgentConfigReq) (*types.AgentConfig, error) { + dbConfig := &database.AgentConfig{ + Name: req.Name, + Config: req.Config, + } + + err := c.agentConfigStore.Create(ctx, dbConfig) + if err != nil { + return nil, fmt.Errorf("failed to create agent config: %w", err) + } + + return &types.AgentConfig{ + ID: dbConfig.ID, + Name: dbConfig.Name, + Config: dbConfig.Config, + CreatedAt: dbConfig.CreatedAt, + UpdatedAt: dbConfig.UpdatedAt, + }, nil +} + +func (c *agentConfigComponentImpl) Delete(ctx context.Context, id int64) error { + err := c.agentConfigStore.Delete(ctx, id) + if err != nil { + return fmt.Errorf("failed to delete agent config: %w", err) + } + return nil +} + +func (c *agentConfigComponentImpl) Update(ctx context.Context, id int64, req *types.UpdateAgentConfigReq) (*types.AgentConfig, error) { + dbConfig, err := c.agentConfigStore.GetByID(ctx, id) + if err != nil { + return nil, fmt.Errorf("failed to get agent config: %w", err) + } + if dbConfig == nil { + return nil, fmt.Errorf("agent config not found") + } + + if req.Name != nil && *req.Name != "" { + dbConfig.Name = *req.Name + } + if req.Config != nil { + dbConfig.Config = *req.Config + } + + err = c.agentConfigStore.Update(ctx, dbConfig) + if err != nil { + return nil, fmt.Errorf("failed to update agent config: %w", err) + } + + return &types.AgentConfig{ + ID: dbConfig.ID, + Name: dbConfig.Name, + Config: dbConfig.Config, + CreatedAt: dbConfig.CreatedAt, + UpdatedAt: dbConfig.UpdatedAt, + }, nil +} diff --git a/component/agent_config_test.go b/component/agent_config_test.go new file mode 100644 index 000000000..28c80d63f --- /dev/null +++ b/component/agent_config_test.go @@ -0,0 +1,392 @@ +//go:build ee || saas + +package component + +import ( + "context" + "errors" + "testing" + "time" + + "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" + mockdatabase "opencsg.com/csghub-server/_mocks/opencsg.com/csghub-server/builder/store/database" + "opencsg.com/csghub-server/builder/store/database" + "opencsg.com/csghub-server/common/types" +) + +// testAgentConfigWithMocks represents the test structure for AgentConfigComponent +type testAgentConfigWithMocks struct { + AgentConfigComponent + mocks *agentConfigMocks +} + +// agentConfigMocks contains all the mocks needed for AgentConfigComponent testing +type agentConfigMocks struct { + agentConfigStore *mockdatabase.MockAgentConfigStore +} + +// initializeTestAgentConfigComponent creates a test AgentConfigComponent with mocks +func initializeTestAgentConfigComponent(_ context.Context, t interface { + Cleanup(func()) + mock.TestingT +}) *testAgentConfigWithMocks { + // Create mocks + agentConfigStore := mockdatabase.NewMockAgentConfigStore(t) + + // Create mocks struct + mocks := &agentConfigMocks{ + agentConfigStore: agentConfigStore, + } + + // Create component implementation + component := &agentConfigComponentImpl{ + agentConfigStore: agentConfigStore, + } + + return &testAgentConfigWithMocks{ + AgentConfigComponent: component, + mocks: mocks, + } +} + +func TestAgentConfigComponent_GetByName(t *testing.T) { + ctx := context.Background() + + t.Run("success", func(t *testing.T) { + ac := initializeTestAgentConfigComponent(ctx, t) + + now := time.Now() + dbConfig := &database.AgentConfig{ + ID: 1, + Name: "instance", + Config: map[string]any{ + "code_instance_quota_per_user": 5, + "langflow_instance_quota_per_user": 10, + }, + } + // Set CreatedAt and UpdatedAt directly (times is embedded) + dbConfig.CreatedAt = now + dbConfig.UpdatedAt = now + + ac.mocks.agentConfigStore.EXPECT().GetByName(ctx, "instance").Return(dbConfig, nil) + + result, err := ac.GetByName(ctx, "instance") + + require.NoError(t, err) + require.NotNil(t, result) + require.Equal(t, int64(1), result.ID) + require.Equal(t, "instance", result.Name) + // Handle both float64 (from JSON) and int types + codeQuota := result.Config["code_instance_quota_per_user"] + if quotaFloat, ok := codeQuota.(float64); ok { + require.Equal(t, 5, int(quotaFloat)) + } else if quotaInt, ok := codeQuota.(int); ok { + require.Equal(t, 5, quotaInt) + } else { + t.Fatalf("unexpected type for code_instance_quota_per_user: %T", codeQuota) + } + langflowQuota := result.Config["langflow_instance_quota_per_user"] + if quotaFloat, ok := langflowQuota.(float64); ok { + require.Equal(t, 10, int(quotaFloat)) + } else if quotaInt, ok := langflowQuota.(int); ok { + require.Equal(t, 10, quotaInt) + } else { + t.Fatalf("unexpected type for langflow_instance_quota_per_user: %T", langflowQuota) + } + require.Equal(t, dbConfig.CreatedAt, result.CreatedAt) + require.Equal(t, dbConfig.UpdatedAt, result.UpdatedAt) + }) + + t.Run("database error", func(t *testing.T) { + ac := initializeTestAgentConfigComponent(ctx, t) + + ac.mocks.agentConfigStore.EXPECT().GetByName(ctx, "instance").Return(nil, errors.New("database error")) + + result, err := ac.GetByName(ctx, "instance") + + require.Error(t, err) + require.Nil(t, result) + require.Contains(t, err.Error(), "failed to get agent config by name") + }) + + t.Run("config not found", func(t *testing.T) { + ac := initializeTestAgentConfigComponent(ctx, t) + + ac.mocks.agentConfigStore.EXPECT().GetByName(ctx, "instance").Return(nil, nil) + + result, err := ac.GetByName(ctx, "instance") + + require.Error(t, err) + require.Nil(t, result) + require.Contains(t, err.Error(), "agent config not found") + }) +} + +func TestAgentConfigComponent_Update(t *testing.T) { + ctx := context.Background() + + t.Run("success", func(t *testing.T) { + ac := initializeTestAgentConfigComponent(ctx, t) + + now := time.Now() + existingConfig := &database.AgentConfig{ + ID: 1, + Name: "instance", + Config: map[string]any{ + "code_instance_quota_per_user": 5, + "langflow_instance_quota_per_user": 10, + }, + } + existingConfig.CreatedAt = now + existingConfig.UpdatedAt = now + + newConfig := map[string]any{ + "code_instance_quota_per_user": 15, + "langflow_instance_quota_per_user": 20, + "new_setting": "new_value", + } + + req := &types.UpdateAgentConfigReq{ + Config: &newConfig, + } + + // Mock GetByID to return existing config + ac.mocks.agentConfigStore.EXPECT().GetByID(ctx, int64(1)).Return(existingConfig, nil) + + // Mock Update - the config should be replaced entirely + ac.mocks.agentConfigStore.EXPECT().Update(ctx, mock.MatchedBy(func(c *database.AgentConfig) bool { + return c.ID == existingConfig.ID && + c.Config["code_instance_quota_per_user"] == 15 && + c.Config["langflow_instance_quota_per_user"] == 20 && + c.Config["new_setting"] == "new_value" && + len(c.Config) == 3 // Should have exactly 3 keys (old keys replaced) + })).Return(nil) + + result, err := ac.Update(ctx, 1, req) + + require.NoError(t, err) + require.NotNil(t, result) + require.Equal(t, int64(1), result.ID) + // Handle both float64 (from JSON) and int types + codeQuota := result.Config["code_instance_quota_per_user"] + if quotaFloat, ok := codeQuota.(float64); ok { + require.Equal(t, 15, int(quotaFloat)) + } else if quotaInt, ok := codeQuota.(int); ok { + require.Equal(t, 15, quotaInt) + } else { + t.Fatalf("unexpected type for code_instance_quota_per_user: %T", codeQuota) + } + langflowQuota := result.Config["langflow_instance_quota_per_user"] + if quotaFloat, ok := langflowQuota.(float64); ok { + require.Equal(t, 20, int(quotaFloat)) + } else if quotaInt, ok := langflowQuota.(int); ok { + require.Equal(t, 20, quotaInt) + } else { + t.Fatalf("unexpected type for langflow_instance_quota_per_user: %T", langflowQuota) + } + require.Equal(t, "new_value", result.Config["new_setting"]) + }) + + t.Run("get error", func(t *testing.T) { + ac := initializeTestAgentConfigComponent(ctx, t) + + config := map[string]any{ + "code_instance_quota_per_user": 15, + } + req := &types.UpdateAgentConfigReq{ + Config: &config, + } + + ac.mocks.agentConfigStore.EXPECT().GetByID(ctx, int64(1)).Return(nil, errors.New("database error")) + + result, err := ac.Update(ctx, 1, req) + + require.Error(t, err) + require.Nil(t, result) + require.Contains(t, err.Error(), "failed to get agent config") + }) + + t.Run("config not found", func(t *testing.T) { + ac := initializeTestAgentConfigComponent(ctx, t) + + config := map[string]any{ + "code_instance_quota_per_user": 15, + } + req := &types.UpdateAgentConfigReq{ + Config: &config, + } + + ac.mocks.agentConfigStore.EXPECT().GetByID(ctx, int64(1)).Return(nil, nil) + + result, err := ac.Update(ctx, 1, req) + + require.Error(t, err) + require.Nil(t, result) + require.Contains(t, err.Error(), "agent config not found") + }) + + t.Run("update error", func(t *testing.T) { + ac := initializeTestAgentConfigComponent(ctx, t) + + now := time.Now() + existingConfig := &database.AgentConfig{ + ID: 1, + Name: "instance", + Config: map[string]any{ + "code_instance_quota_per_user": 5, + }, + } + existingConfig.CreatedAt = now + existingConfig.UpdatedAt = now + + config := map[string]any{ + "code_instance_quota_per_user": 15, + } + req := &types.UpdateAgentConfigReq{ + Config: &config, + } + + ac.mocks.agentConfigStore.EXPECT().GetByID(ctx, int64(1)).Return(existingConfig, nil) + ac.mocks.agentConfigStore.EXPECT().Update(ctx, mock.Anything).Return(errors.New("update error")) + + result, err := ac.Update(ctx, 1, req) + + require.Error(t, err) + require.Nil(t, result) + require.Contains(t, err.Error(), "failed to update agent config") + }) + + t.Run("replace entire config", func(t *testing.T) { + ac := initializeTestAgentConfigComponent(ctx, t) + + now := time.Now() + existingConfig := &database.AgentConfig{ + ID: 1, + Name: "old-name", + Config: map[string]any{ + "code_instance_quota_per_user": 5, + "langflow_instance_quota_per_user": 10, + "old_setting": "old_value", + }, + } + existingConfig.CreatedAt = now + existingConfig.UpdatedAt = now + + // New config only has one key - old keys should be removed + newConfig := map[string]any{ + "code_instance_quota_per_user": 15, + } + + req := &types.UpdateAgentConfigReq{ + Config: &newConfig, + } + + ac.mocks.agentConfigStore.EXPECT().GetByID(ctx, int64(1)).Return(existingConfig, nil) + ac.mocks.agentConfigStore.EXPECT().Update(ctx, mock.MatchedBy(func(c *database.AgentConfig) bool { + // Verify that old keys are removed and only new key exists, name unchanged + _, hasOldKey := c.Config["langflow_instance_quota_per_user"] + _, hasOldSetting := c.Config["old_setting"] + _, hasNewKey := c.Config["code_instance_quota_per_user"] + return !hasOldKey && !hasOldSetting && hasNewKey && len(c.Config) == 1 && c.Name == "old-name" + })).Return(nil) + + result, err := ac.Update(ctx, 1, req) + + require.NoError(t, err) + require.NotNil(t, result) + // Handle both float64 (from JSON) and int types + codeQuota := result.Config["code_instance_quota_per_user"] + if quotaFloat, ok := codeQuota.(float64); ok { + require.Equal(t, 15, int(quotaFloat)) + } else if quotaInt, ok := codeQuota.(int); ok { + require.Equal(t, 15, quotaInt) + } else { + t.Fatalf("unexpected type for code_instance_quota_per_user: %T", codeQuota) + } + _, exists := result.Config["langflow_instance_quota_per_user"] + require.False(t, exists, "old key should be removed") + }) + + t.Run("update name only", func(t *testing.T) { + ac := initializeTestAgentConfigComponent(ctx, t) + + now := time.Now() + existingConfig := &database.AgentConfig{ + ID: 1, + Name: "old-name", + Config: map[string]any{ + "code_instance_quota_per_user": 5, + }, + } + existingConfig.CreatedAt = now + existingConfig.UpdatedAt = now + + name := "new-name" + req := &types.UpdateAgentConfigReq{ + Name: &name, + } + + ac.mocks.agentConfigStore.EXPECT().GetByID(ctx, int64(1)).Return(existingConfig, nil) + ac.mocks.agentConfigStore.EXPECT().Update(ctx, mock.MatchedBy(func(c *database.AgentConfig) bool { + return c.Name == "new-name" && c.Config["code_instance_quota_per_user"] == 5 + })).Return(nil) + + result, err := ac.Update(ctx, 1, req) + + require.NoError(t, err) + require.NotNil(t, result) + require.Equal(t, "new-name", result.Name) + codeQuota := result.Config["code_instance_quota_per_user"] + if quotaFloat, ok := codeQuota.(float64); ok { + require.Equal(t, 5, int(quotaFloat)) + } else if quotaInt, ok := codeQuota.(int); ok { + require.Equal(t, 5, quotaInt) + } else { + t.Fatalf("unexpected type for code_instance_quota_per_user: %T", codeQuota) + } + }) + + t.Run("update name and config", func(t *testing.T) { + ac := initializeTestAgentConfigComponent(ctx, t) + + now := time.Now() + existingConfig := &database.AgentConfig{ + ID: 1, + Name: "old-name", + Config: map[string]any{ + "code_instance_quota_per_user": 5, + }, + } + existingConfig.CreatedAt = now + existingConfig.UpdatedAt = now + + name := "new-name" + newConfig := map[string]any{ + "code_instance_quota_per_user": 10, + } + req := &types.UpdateAgentConfigReq{ + Name: &name, + Config: &newConfig, + } + + ac.mocks.agentConfigStore.EXPECT().GetByID(ctx, int64(1)).Return(existingConfig, nil) + ac.mocks.agentConfigStore.EXPECT().Update(ctx, mock.MatchedBy(func(c *database.AgentConfig) bool { + return c.Name == "new-name" && c.Config["code_instance_quota_per_user"] == 10 + })).Return(nil) + + result, err := ac.Update(ctx, 1, req) + + require.NoError(t, err) + require.NotNil(t, result) + require.Equal(t, "new-name", result.Name) + codeQuota := result.Config["code_instance_quota_per_user"] + if quotaFloat, ok := codeQuota.(float64); ok { + require.Equal(t, 10, int(quotaFloat)) + } else if quotaInt, ok := codeQuota.(int); ok { + require.Equal(t, 10, quotaInt) + } else { + t.Fatalf("unexpected type for code_instance_quota_per_user: %T", codeQuota) + } + }) +}