diff --git a/db/config.go b/db/config.go index 95a2c770d..29aeb2c1a 100644 --- a/db/config.go +++ b/db/config.go @@ -2,6 +2,7 @@ package db import ( "fmt" + "log" "os" "github.com/rs/xid" @@ -456,3 +457,22 @@ func (db database) UserHasManageBountyRoles(pubKeyFromAuth string, uuid string) } return true } + +func (db database) ProcessUpdateTicketsWithoutGroup() { + // get all tickets without group + tickets, err := db.GetTicketsWithoutGroup() + + if err != nil { + log.Printf("Error getting tickets without group: %v", err) + return + } + + // update each ticket with group uuid + for _, ticket := range tickets { + fmt.Println("ticket from process", ticket) + err := db.UpdateTicketsWithoutGroup(ticket) + if err != nil { + log.Printf("Error updating ticket: %v", err) + } + } +} diff --git a/db/config_test.go b/db/config_test.go index 2c92099e0..cf69243ba 100644 --- a/db/config_test.go +++ b/db/config_test.go @@ -1,9 +1,11 @@ package db import ( + "fmt" "testing" "time" + "github.com/google/uuid" "github.com/stretchr/testify/assert" "gorm.io/gorm" ) @@ -152,3 +154,97 @@ func TestUserHasManageBountyRoles(t *testing.T) { assert.False(t, result, "Expected UserHasManageBountyRoles to return false for user without all bounty roles") }) } + +func TestProcessUpdateTicketsWithoutGroup(t *testing.T) { + InitTestDB() + + // create person + now := time.Now() + + person := Person{ + Uuid: uuid.New().String(), + OwnerPubKey: "testfeaturepubkeyProcess", + OwnerAlias: "testfeaturealiasProcess", + Description: "testfeaturedescriptionProcess", + Created: &now, + Updated: &now, + Deleted: false, + } + + // create person + TestDB.CreateOrEditPerson(person) + + workspace := Workspace{ + Uuid: uuid.New().String(), + Name: "Test tickets process space", + Created: &now, + Updated: &now, + } + + // create workspace + TestDB.CreateOrEditWorkspace(workspace) + + workspaceFeatures := WorkspaceFeatures{ + Uuid: uuid.New().String(), + WorkspaceUuid: workspace.Uuid, + Name: "test process feature", + Brief: "test get process brief", + Requirements: "Test get process requirements", + Architecture: "Test get process architecture", + Url: "Test get process url", + Priority: 1, + Created: &now, + Updated: &now, + CreatedBy: "test", + UpdatedBy: "test", + } + + // create WorkspaceFeatures + TestDB.CreateOrEditFeature(workspaceFeatures) + + featurePhase := FeaturePhase{ + Uuid: uuid.New().String(), + FeatureUuid: workspaceFeatures.Uuid, + Name: "test get process feature phase", + Priority: 1, + Created: &now, + Updated: &now, + } + + // create FeaturePhase + TestDB.CreateOrEditFeaturePhase(featurePhase) + + ticket := Tickets{ + UUID: uuid.New(), + FeatureUUID: workspaceFeatures.Uuid, + PhaseUUID: featurePhase.Uuid, + Name: "test get process ticket", + CreatedAt: now, + UpdatedAt: now, + } + + // create ticket + TestDB.CreateOrEditTicket(&ticket) + + // process update tickets without group + TestDB.ProcessUpdateTicketsWithoutGroup() + + // get tickets without group and assert that there is 0 + tickets, err := TestDB.GetTicketsWithoutGroup() + assert.NoError(t, err) + assert.Equal(t, 0, len(tickets)) + + // get ticket and assert that the ticket group is the same as the ticket uuid + ticket, err = TestDB.GetTicket(ticket.UUID.String()) + + fmt.Println("tickets", tickets) + + ticketUuid := ticket.UUID + ticketAuthorID := "12345" + ticketAuthor := Author("HUMAN") + + assert.NoError(t, err) + assert.Equal(t, ticket.TicketGroup, &ticketUuid) + assert.Equal(t, ticket.AuthorID, &ticketAuthorID) + assert.Equal(t, ticket.Author, &ticketAuthor) +} diff --git a/db/interface.go b/db/interface.go index d88150c85..3bdb962e7 100644 --- a/db/interface.go +++ b/db/interface.go @@ -205,4 +205,7 @@ type Database interface { GetCodeGraphsByWorkspaceUuid(workspace_uuid string) ([]WorkspaceCodeGraph, error) CreateOrEditCodeGraph(m WorkspaceCodeGraph) (WorkspaceCodeGraph, error) DeleteCodeGraph(workspace_uuid string, uuid string) error + GetTicketsWithoutGroup() ([]Tickets, error) + UpdateTicketsWithoutGroup(ticket Tickets) error + ProcessUpdateTicketsWithoutGroup() } diff --git a/db/tickets.go b/db/tickets.go index adfef7253..b67197520 100644 --- a/db/tickets.go +++ b/db/tickets.go @@ -150,3 +150,44 @@ func (db database) GetTicketsByPhaseUUID(featureUUID string, phaseUUID string) ( return tickets, nil } + +func (db database) GetTicketsWithoutGroup() ([]Tickets, error) { + var tickets []Tickets + + result := db.db. + Where("ticket_group IS NULL OR ticket_group = ?", uuid.Nil).Find(&tickets) + + if result.Error != nil { + return nil, fmt.Errorf("failed to fetch tickets: %w", result.Error) + } + + if result.RowsAffected == 0 { + return []Tickets{}, nil + } + + return tickets, nil +} + +func (db database) UpdateTicketsWithoutGroup(ticket Tickets) error { + data := map[string]interface{}{} + + data["ticket_group"] = ticket.UUID + + if ticket.AuthorID == nil { + data["author_id"] = "12345" + } + + if ticket.Author == nil { + data["author"] = "HUMAN" + } + + fmt.Println("data ===", data) + + result := db.db.Model(&Tickets{}).Where("uuid = ?", ticket.UUID).Updates(data) + + if result.Error != nil { + return fmt.Errorf("failed to update ticket: %w", result.Error) + } + + return nil +} diff --git a/main.go b/main.go index 2589bcd2f..793e6ae6c 100644 --- a/main.go +++ b/main.go @@ -20,10 +20,7 @@ import ( ) func main() { - var err error - - err = godotenv.Load() - if err != nil { + if err := godotenv.Load(); err != nil { fmt.Println("no .env file") } @@ -31,6 +28,8 @@ func main() { db.InitRedis() db.InitCache() db.InitRoles() + db.DB.ProcessUpdateTicketsWithoutGroup() + // Config has to be inited before JWT, if not it will lead to NO JWT error config.InitConfig() auth.InitJwt() diff --git a/mocks/Database.go b/mocks/Database.go index 42a1b19f2..dc67473c0 100644 --- a/mocks/Database.go +++ b/mocks/Database.go @@ -930,6 +930,62 @@ func (_c *Database_CreateOrEditBounty_Call) RunAndReturn(run func(db.NewBounty) return _c } +// CreateOrEditCodeGraph provides a mock function with given fields: m +func (_m *Database) CreateOrEditCodeGraph(m db.WorkspaceCodeGraph) (db.WorkspaceCodeGraph, error) { + ret := _m.Called(m) + + if len(ret) == 0 { + panic("no return value specified for CreateOrEditCodeGraph") + } + + var r0 db.WorkspaceCodeGraph + var r1 error + if rf, ok := ret.Get(0).(func(db.WorkspaceCodeGraph) (db.WorkspaceCodeGraph, error)); ok { + return rf(m) + } + if rf, ok := ret.Get(0).(func(db.WorkspaceCodeGraph) db.WorkspaceCodeGraph); ok { + r0 = rf(m) + } else { + r0 = ret.Get(0).(db.WorkspaceCodeGraph) + } + + if rf, ok := ret.Get(1).(func(db.WorkspaceCodeGraph) error); ok { + r1 = rf(m) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Database_CreateOrEditCodeGraph_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateOrEditCodeGraph' +type Database_CreateOrEditCodeGraph_Call struct { + *mock.Call +} + +// CreateOrEditCodeGraph is a helper method to define mock.On call +// - m db.WorkspaceCodeGraph +func (_e *Database_Expecter) CreateOrEditCodeGraph(m interface{}) *Database_CreateOrEditCodeGraph_Call { + return &Database_CreateOrEditCodeGraph_Call{Call: _e.mock.On("CreateOrEditCodeGraph", m)} +} + +func (_c *Database_CreateOrEditCodeGraph_Call) Run(run func(m db.WorkspaceCodeGraph)) *Database_CreateOrEditCodeGraph_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(db.WorkspaceCodeGraph)) + }) + return _c +} + +func (_c *Database_CreateOrEditCodeGraph_Call) Return(_a0 db.WorkspaceCodeGraph, _a1 error) *Database_CreateOrEditCodeGraph_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Database_CreateOrEditCodeGraph_Call) RunAndReturn(run func(db.WorkspaceCodeGraph) (db.WorkspaceCodeGraph, error)) *Database_CreateOrEditCodeGraph_Call { + _c.Call.Return(run) + return _c +} + // CreateOrEditFeature provides a mock function with given fields: m func (_m *Database) CreateOrEditFeature(m db.WorkspaceFeatures) (db.WorkspaceFeatures, error) { ret := _m.Called(m) @@ -1715,6 +1771,53 @@ func (_c *Database_DeleteBounty_Call) RunAndReturn(run func(string, string) (db. return _c } +// DeleteCodeGraph provides a mock function with given fields: workspace_uuid, uuid +func (_m *Database) DeleteCodeGraph(workspace_uuid string, uuid string) error { + ret := _m.Called(workspace_uuid, uuid) + + if len(ret) == 0 { + panic("no return value specified for DeleteCodeGraph") + } + + var r0 error + if rf, ok := ret.Get(0).(func(string, string) error); ok { + r0 = rf(workspace_uuid, uuid) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Database_DeleteCodeGraph_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteCodeGraph' +type Database_DeleteCodeGraph_Call struct { + *mock.Call +} + +// DeleteCodeGraph is a helper method to define mock.On call +// - workspace_uuid string +// - uuid string +func (_e *Database_Expecter) DeleteCodeGraph(workspace_uuid interface{}, uuid interface{}) *Database_DeleteCodeGraph_Call { + return &Database_DeleteCodeGraph_Call{Call: _e.mock.On("DeleteCodeGraph", workspace_uuid, uuid)} +} + +func (_c *Database_DeleteCodeGraph_Call) Run(run func(workspace_uuid string, uuid string)) *Database_DeleteCodeGraph_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(string)) + }) + return _c +} + +func (_c *Database_DeleteCodeGraph_Call) Return(_a0 error) *Database_DeleteCodeGraph_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Database_DeleteCodeGraph_Call) RunAndReturn(run func(string, string) error) *Database_DeleteCodeGraph_Call { + _c.Call.Return(run) + return _c +} + // DeleteFeatureByUuid provides a mock function with given fields: uuid func (_m *Database) DeleteFeatureByUuid(uuid string) error { ret := _m.Called(uuid) @@ -2723,92 +2826,6 @@ func (_c *Database_GetBountiesByFeatureAndPhaseUuid_Call) RunAndReturn(run func( return _c } -// GetProductBrief provides a mock function with given fields: workspaceUuid -func (_m *Database) GetProductBrief(workspaceUuid string) (string, error) { - ret := _m.Called(workspaceUuid) - - var r0 string - if rf, ok := ret.Get(0).(func(string) string); ok { - r0 = rf(workspaceUuid) - } else { - r0 = ret.Get(0).(string) - } - - var r1 error - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(workspaceUuid) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Database_GetProductBrief_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetProductBrief' -type Database_GetProductBrief_Call struct { - *mock.Call -} - -// GetProductBrief is a helper method to define mock.On call -func (_e *Database_Expecter) GetProductBrief(workspaceUuid interface{}) *Database_GetProductBrief_Call { - return &Database_GetProductBrief_Call{Call: _e.mock.On("GetProductBrief", workspaceUuid)} -} - -func (_c *Database_GetProductBrief_Call) Run(run func(workspaceUuid string)) *Database_GetProductBrief_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) - }) - return _c -} - -func (_c *Database_GetProductBrief_Call) Return(_a0 string, _a1 error) *Database_GetProductBrief_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -// GetFeatureBrief provides a mock function with given fields: featureUuid -func (_m *Database) GetFeatureBrief(featureUuid string) (string, error) { - ret := _m.Called(featureUuid) - - var r0 string - if rf, ok := ret.Get(0).(func(string) string); ok { - r0 = rf(featureUuid) - } else { - r0 = ret.Get(0).(string) - } - - var r1 error - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(featureUuid) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Database_GetFeatureBrief_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetFeatureBrief' -type Database_GetFeatureBrief_Call struct { - *mock.Call -} - -// GetFeatureBrief is a helper method to define mock.On call -func (_e *Database_Expecter) GetFeatureBrief(featureUuid interface{}) *Database_GetFeatureBrief_Call { - return &Database_GetFeatureBrief_Call{Call: _e.mock.On("GetFeatureBrief", featureUuid)} -} - -func (_c *Database_GetFeatureBrief_Call) Run(run func(featureUuid string)) *Database_GetFeatureBrief_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) - }) - return _c -} - -func (_c *Database_GetFeatureBrief_Call) Return(_a0 string, _a1 error) *Database_GetFeatureBrief_Call { - _c.Call.Return(_a0, _a1) - return _c -} - // GetBountiesByPhaseUuid provides a mock function with given fields: phaseUuid func (_m *Database) GetBountiesByPhaseUuid(phaseUuid string) []db.Bounty { ret := _m.Called(phaseUuid) @@ -3452,6 +3469,120 @@ func (_c *Database_GetChannelsByTribe_Call) RunAndReturn(run func(string) []db.C return _c } +// GetCodeGraphByUUID provides a mock function with given fields: uuid +func (_m *Database) GetCodeGraphByUUID(uuid string) (db.WorkspaceCodeGraph, error) { + ret := _m.Called(uuid) + + if len(ret) == 0 { + panic("no return value specified for GetCodeGraphByUUID") + } + + var r0 db.WorkspaceCodeGraph + var r1 error + if rf, ok := ret.Get(0).(func(string) (db.WorkspaceCodeGraph, error)); ok { + return rf(uuid) + } + if rf, ok := ret.Get(0).(func(string) db.WorkspaceCodeGraph); ok { + r0 = rf(uuid) + } else { + r0 = ret.Get(0).(db.WorkspaceCodeGraph) + } + + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(uuid) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Database_GetCodeGraphByUUID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetCodeGraphByUUID' +type Database_GetCodeGraphByUUID_Call struct { + *mock.Call +} + +// GetCodeGraphByUUID is a helper method to define mock.On call +// - uuid string +func (_e *Database_Expecter) GetCodeGraphByUUID(uuid interface{}) *Database_GetCodeGraphByUUID_Call { + return &Database_GetCodeGraphByUUID_Call{Call: _e.mock.On("GetCodeGraphByUUID", uuid)} +} + +func (_c *Database_GetCodeGraphByUUID_Call) Run(run func(uuid string)) *Database_GetCodeGraphByUUID_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *Database_GetCodeGraphByUUID_Call) Return(_a0 db.WorkspaceCodeGraph, _a1 error) *Database_GetCodeGraphByUUID_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Database_GetCodeGraphByUUID_Call) RunAndReturn(run func(string) (db.WorkspaceCodeGraph, error)) *Database_GetCodeGraphByUUID_Call { + _c.Call.Return(run) + return _c +} + +// GetCodeGraphsByWorkspaceUuid provides a mock function with given fields: workspace_uuid +func (_m *Database) GetCodeGraphsByWorkspaceUuid(workspace_uuid string) ([]db.WorkspaceCodeGraph, error) { + ret := _m.Called(workspace_uuid) + + if len(ret) == 0 { + panic("no return value specified for GetCodeGraphsByWorkspaceUuid") + } + + var r0 []db.WorkspaceCodeGraph + var r1 error + if rf, ok := ret.Get(0).(func(string) ([]db.WorkspaceCodeGraph, error)); ok { + return rf(workspace_uuid) + } + if rf, ok := ret.Get(0).(func(string) []db.WorkspaceCodeGraph); ok { + r0 = rf(workspace_uuid) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]db.WorkspaceCodeGraph) + } + } + + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(workspace_uuid) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Database_GetCodeGraphsByWorkspaceUuid_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetCodeGraphsByWorkspaceUuid' +type Database_GetCodeGraphsByWorkspaceUuid_Call struct { + *mock.Call +} + +// GetCodeGraphsByWorkspaceUuid is a helper method to define mock.On call +// - workspace_uuid string +func (_e *Database_Expecter) GetCodeGraphsByWorkspaceUuid(workspace_uuid interface{}) *Database_GetCodeGraphsByWorkspaceUuid_Call { + return &Database_GetCodeGraphsByWorkspaceUuid_Call{Call: _e.mock.On("GetCodeGraphsByWorkspaceUuid", workspace_uuid)} +} + +func (_c *Database_GetCodeGraphsByWorkspaceUuid_Call) Run(run func(workspace_uuid string)) *Database_GetCodeGraphsByWorkspaceUuid_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *Database_GetCodeGraphsByWorkspaceUuid_Call) Return(_a0 []db.WorkspaceCodeGraph, _a1 error) *Database_GetCodeGraphsByWorkspaceUuid_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Database_GetCodeGraphsByWorkspaceUuid_Call) RunAndReturn(run func(string) ([]db.WorkspaceCodeGraph, error)) *Database_GetCodeGraphsByWorkspaceUuid_Call { + _c.Call.Return(run) + return _c +} + // GetConnectionCode provides a mock function with given fields: func (_m *Database) GetConnectionCode() db.ConnectionCodesShort { ret := _m.Called() @@ -3555,6 +3686,62 @@ func (_c *Database_GetCreatedBounties_Call) RunAndReturn(run func(*http.Request) return _c } +// GetFeatureBrief provides a mock function with given fields: featureUuid +func (_m *Database) GetFeatureBrief(featureUuid string) (string, error) { + ret := _m.Called(featureUuid) + + if len(ret) == 0 { + panic("no return value specified for GetFeatureBrief") + } + + var r0 string + var r1 error + if rf, ok := ret.Get(0).(func(string) (string, error)); ok { + return rf(featureUuid) + } + if rf, ok := ret.Get(0).(func(string) string); ok { + r0 = rf(featureUuid) + } else { + r0 = ret.Get(0).(string) + } + + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(featureUuid) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Database_GetFeatureBrief_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetFeatureBrief' +type Database_GetFeatureBrief_Call struct { + *mock.Call +} + +// GetFeatureBrief is a helper method to define mock.On call +// - featureUuid string +func (_e *Database_Expecter) GetFeatureBrief(featureUuid interface{}) *Database_GetFeatureBrief_Call { + return &Database_GetFeatureBrief_Call{Call: _e.mock.On("GetFeatureBrief", featureUuid)} +} + +func (_c *Database_GetFeatureBrief_Call) Run(run func(featureUuid string)) *Database_GetFeatureBrief_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *Database_GetFeatureBrief_Call) Return(_a0 string, _a1 error) *Database_GetFeatureBrief_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Database_GetFeatureBrief_Call) RunAndReturn(run func(string) (string, error)) *Database_GetFeatureBrief_Call { + _c.Call.Return(run) + return _c +} + // GetFeatureByUuid provides a mock function with given fields: uuid func (_m *Database) GetFeatureByUuid(uuid string) db.WorkspaceFeatures { ret := _m.Called(uuid) @@ -5527,6 +5714,62 @@ func (_c *Database_GetProcessingMapsByType_Call) RunAndReturn(run func(string) ( return _c } +// GetProductBrief provides a mock function with given fields: workspaceUuid +func (_m *Database) GetProductBrief(workspaceUuid string) (string, error) { + ret := _m.Called(workspaceUuid) + + if len(ret) == 0 { + panic("no return value specified for GetProductBrief") + } + + var r0 string + var r1 error + if rf, ok := ret.Get(0).(func(string) (string, error)); ok { + return rf(workspaceUuid) + } + if rf, ok := ret.Get(0).(func(string) string); ok { + r0 = rf(workspaceUuid) + } else { + r0 = ret.Get(0).(string) + } + + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(workspaceUuid) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Database_GetProductBrief_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetProductBrief' +type Database_GetProductBrief_Call struct { + *mock.Call +} + +// GetProductBrief is a helper method to define mock.On call +// - workspaceUuid string +func (_e *Database_Expecter) GetProductBrief(workspaceUuid interface{}) *Database_GetProductBrief_Call { + return &Database_GetProductBrief_Call{Call: _e.mock.On("GetProductBrief", workspaceUuid)} +} + +func (_c *Database_GetProductBrief_Call) Run(run func(workspaceUuid string)) *Database_GetProductBrief_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *Database_GetProductBrief_Call) Return(_a0 string, _a1 error) *Database_GetProductBrief_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Database_GetProductBrief_Call) RunAndReturn(run func(string) (string, error)) *Database_GetProductBrief_Call { + _c.Call.Return(run) + return _c +} + // GetSumOfDeposits provides a mock function with given fields: workspace_uuid func (_m *Database) GetSumOfDeposits(workspace_uuid string) uint { ret := _m.Called(workspace_uuid) @@ -5581,65 +5824,182 @@ func (_m *Database) GetSumOfWithdrawal(workspace_uuid string) uint { panic("no return value specified for GetSumOfWithdrawal") } - var r0 uint - if rf, ok := ret.Get(0).(func(string) uint); ok { - r0 = rf(workspace_uuid) + var r0 uint + if rf, ok := ret.Get(0).(func(string) uint); ok { + r0 = rf(workspace_uuid) + } else { + r0 = ret.Get(0).(uint) + } + + return r0 +} + +// Database_GetSumOfWithdrawal_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSumOfWithdrawal' +type Database_GetSumOfWithdrawal_Call struct { + *mock.Call +} + +// GetSumOfWithdrawal is a helper method to define mock.On call +// - workspace_uuid string +func (_e *Database_Expecter) GetSumOfWithdrawal(workspace_uuid interface{}) *Database_GetSumOfWithdrawal_Call { + return &Database_GetSumOfWithdrawal_Call{Call: _e.mock.On("GetSumOfWithdrawal", workspace_uuid)} +} + +func (_c *Database_GetSumOfWithdrawal_Call) Run(run func(workspace_uuid string)) *Database_GetSumOfWithdrawal_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *Database_GetSumOfWithdrawal_Call) Return(_a0 uint) *Database_GetSumOfWithdrawal_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Database_GetSumOfWithdrawal_Call) RunAndReturn(run func(string) uint) *Database_GetSumOfWithdrawal_Call { + _c.Call.Return(run) + return _c +} + +// GetTicket provides a mock function with given fields: uuid +func (_m *Database) GetTicket(uuid string) (db.Tickets, error) { + ret := _m.Called(uuid) + + if len(ret) == 0 { + panic("no return value specified for GetTicket") + } + + var r0 db.Tickets + var r1 error + if rf, ok := ret.Get(0).(func(string) (db.Tickets, error)); ok { + return rf(uuid) + } + if rf, ok := ret.Get(0).(func(string) db.Tickets); ok { + r0 = rf(uuid) + } else { + r0 = ret.Get(0).(db.Tickets) + } + + if rf, ok := ret.Get(1).(func(string) error); ok { + r1 = rf(uuid) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Database_GetTicket_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTicket' +type Database_GetTicket_Call struct { + *mock.Call +} + +// GetTicket is a helper method to define mock.On call +// - uuid string +func (_e *Database_Expecter) GetTicket(uuid interface{}) *Database_GetTicket_Call { + return &Database_GetTicket_Call{Call: _e.mock.On("GetTicket", uuid)} +} + +func (_c *Database_GetTicket_Call) Run(run func(uuid string)) *Database_GetTicket_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string)) + }) + return _c +} + +func (_c *Database_GetTicket_Call) Return(_a0 db.Tickets, _a1 error) *Database_GetTicket_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Database_GetTicket_Call) RunAndReturn(run func(string) (db.Tickets, error)) *Database_GetTicket_Call { + _c.Call.Return(run) + return _c +} + +// GetTicketsByPhaseUUID provides a mock function with given fields: featureUUID, phaseUUID +func (_m *Database) GetTicketsByPhaseUUID(featureUUID string, phaseUUID string) ([]db.Tickets, error) { + ret := _m.Called(featureUUID, phaseUUID) + + if len(ret) == 0 { + panic("no return value specified for GetTicketsByPhaseUUID") + } + + var r0 []db.Tickets + var r1 error + if rf, ok := ret.Get(0).(func(string, string) ([]db.Tickets, error)); ok { + return rf(featureUUID, phaseUUID) + } + if rf, ok := ret.Get(0).(func(string, string) []db.Tickets); ok { + r0 = rf(featureUUID, phaseUUID) + } else { + if ret.Get(0) != nil { + r0 = ret.Get(0).([]db.Tickets) + } + } + + if rf, ok := ret.Get(1).(func(string, string) error); ok { + r1 = rf(featureUUID, phaseUUID) } else { - r0 = ret.Get(0).(uint) + r1 = ret.Error(1) } - return r0 + return r0, r1 } -// Database_GetSumOfWithdrawal_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSumOfWithdrawal' -type Database_GetSumOfWithdrawal_Call struct { +// Database_GetTicketsByPhaseUUID_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTicketsByPhaseUUID' +type Database_GetTicketsByPhaseUUID_Call struct { *mock.Call } -// GetSumOfWithdrawal is a helper method to define mock.On call -// - workspace_uuid string -func (_e *Database_Expecter) GetSumOfWithdrawal(workspace_uuid interface{}) *Database_GetSumOfWithdrawal_Call { - return &Database_GetSumOfWithdrawal_Call{Call: _e.mock.On("GetSumOfWithdrawal", workspace_uuid)} +// GetTicketsByPhaseUUID is a helper method to define mock.On call +// - featureUUID string +// - phaseUUID string +func (_e *Database_Expecter) GetTicketsByPhaseUUID(featureUUID interface{}, phaseUUID interface{}) *Database_GetTicketsByPhaseUUID_Call { + return &Database_GetTicketsByPhaseUUID_Call{Call: _e.mock.On("GetTicketsByPhaseUUID", featureUUID, phaseUUID)} } -func (_c *Database_GetSumOfWithdrawal_Call) Run(run func(workspace_uuid string)) *Database_GetSumOfWithdrawal_Call { +func (_c *Database_GetTicketsByPhaseUUID_Call) Run(run func(featureUUID string, phaseUUID string)) *Database_GetTicketsByPhaseUUID_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) + run(args[0].(string), args[1].(string)) }) return _c } -func (_c *Database_GetSumOfWithdrawal_Call) Return(_a0 uint) *Database_GetSumOfWithdrawal_Call { - _c.Call.Return(_a0) +func (_c *Database_GetTicketsByPhaseUUID_Call) Return(_a0 []db.Tickets, _a1 error) *Database_GetTicketsByPhaseUUID_Call { + _c.Call.Return(_a0, _a1) return _c } -func (_c *Database_GetSumOfWithdrawal_Call) RunAndReturn(run func(string) uint) *Database_GetSumOfWithdrawal_Call { +func (_c *Database_GetTicketsByPhaseUUID_Call) RunAndReturn(run func(string, string) ([]db.Tickets, error)) *Database_GetTicketsByPhaseUUID_Call { _c.Call.Return(run) return _c } -// GetTicket provides a mock function with given fields: uuid -func (_m *Database) GetTicket(uuid string) (db.Tickets, error) { - ret := _m.Called(uuid) +// GetTicketsWithoutGroup provides a mock function with given fields: +func (_m *Database) GetTicketsWithoutGroup() ([]db.Tickets, error) { + ret := _m.Called() if len(ret) == 0 { - panic("no return value specified for GetTicket") + panic("no return value specified for GetTicketsWithoutGroup") } - var r0 db.Tickets + var r0 []db.Tickets var r1 error - if rf, ok := ret.Get(0).(func(string) (db.Tickets, error)); ok { - return rf(uuid) + if rf, ok := ret.Get(0).(func() ([]db.Tickets, error)); ok { + return rf() } - if rf, ok := ret.Get(0).(func(string) db.Tickets); ok { - r0 = rf(uuid) + if rf, ok := ret.Get(0).(func() []db.Tickets); ok { + r0 = rf() } else { - r0 = ret.Get(0).(db.Tickets) + if ret.Get(0) != nil { + r0 = ret.Get(0).([]db.Tickets) + } } - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(uuid) + if rf, ok := ret.Get(1).(func() error); ok { + r1 = rf() } else { r1 = ret.Error(1) } @@ -5647,30 +6007,29 @@ func (_m *Database) GetTicket(uuid string) (db.Tickets, error) { return r0, r1 } -// Database_GetTicket_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTicket' -type Database_GetTicket_Call struct { +// Database_GetTicketsWithoutGroup_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetTicketsWithoutGroup' +type Database_GetTicketsWithoutGroup_Call struct { *mock.Call } -// GetTicket is a helper method to define mock.On call -// - uuid string -func (_e *Database_Expecter) GetTicket(uuid interface{}) *Database_GetTicket_Call { - return &Database_GetTicket_Call{Call: _e.mock.On("GetTicket", uuid)} +// GetTicketsWithoutGroup is a helper method to define mock.On call +func (_e *Database_Expecter) GetTicketsWithoutGroup() *Database_GetTicketsWithoutGroup_Call { + return &Database_GetTicketsWithoutGroup_Call{Call: _e.mock.On("GetTicketsWithoutGroup")} } -func (_c *Database_GetTicket_Call) Run(run func(uuid string)) *Database_GetTicket_Call { +func (_c *Database_GetTicketsWithoutGroup_Call) Run(run func()) *Database_GetTicketsWithoutGroup_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) + run() }) return _c } -func (_c *Database_GetTicket_Call) Return(_a0 db.Tickets, _a1 error) *Database_GetTicket_Call { +func (_c *Database_GetTicketsWithoutGroup_Call) Return(_a0 []db.Tickets, _a1 error) *Database_GetTicketsWithoutGroup_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *Database_GetTicket_Call) RunAndReturn(run func(string) (db.Tickets, error)) *Database_GetTicket_Call { +func (_c *Database_GetTicketsWithoutGroup_Call) RunAndReturn(run func() ([]db.Tickets, error)) *Database_GetTicketsWithoutGroup_Call { _c.Call.Return(run) return _c } @@ -7845,6 +8204,38 @@ func (_c *Database_ProcessUpdateBudget_Call) RunAndReturn(run func(db.NewInvoice return _c } +// ProcessUpdateTicketsWithoutGroup provides a mock function with given fields: +func (_m *Database) ProcessUpdateTicketsWithoutGroup() { + _m.Called() +} + +// Database_ProcessUpdateTicketsWithoutGroup_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ProcessUpdateTicketsWithoutGroup' +type Database_ProcessUpdateTicketsWithoutGroup_Call struct { + *mock.Call +} + +// ProcessUpdateTicketsWithoutGroup is a helper method to define mock.On call +func (_e *Database_Expecter) ProcessUpdateTicketsWithoutGroup() *Database_ProcessUpdateTicketsWithoutGroup_Call { + return &Database_ProcessUpdateTicketsWithoutGroup_Call{Call: _e.mock.On("ProcessUpdateTicketsWithoutGroup")} +} + +func (_c *Database_ProcessUpdateTicketsWithoutGroup_Call) Run(run func()) *Database_ProcessUpdateTicketsWithoutGroup_Call { + _c.Call.Run(func(args mock.Arguments) { + run() + }) + return _c +} + +func (_c *Database_ProcessUpdateTicketsWithoutGroup_Call) Return() *Database_ProcessUpdateTicketsWithoutGroup_Call { + _c.Call.Return() + return _c +} + +func (_c *Database_ProcessUpdateTicketsWithoutGroup_Call) RunAndReturn(run func()) *Database_ProcessUpdateTicketsWithoutGroup_Call { + _c.Call.Return(run) + return _c +} + // SatsPaidPercentage provides a mock function with given fields: r, workspace func (_m *Database) SatsPaidPercentage(r db.PaymentDateRange, workspace string) uint { ret := _m.Called(r, workspace) @@ -9082,6 +9473,52 @@ func (_c *Database_UpdateTicket_Call) RunAndReturn(run func(db.Tickets) (db.Tick return _c } +// UpdateTicketsWithoutGroup provides a mock function with given fields: ticket +func (_m *Database) UpdateTicketsWithoutGroup(ticket db.Tickets) error { + ret := _m.Called(ticket) + + if len(ret) == 0 { + panic("no return value specified for UpdateTicketsWithoutGroup") + } + + var r0 error + if rf, ok := ret.Get(0).(func(db.Tickets) error); ok { + r0 = rf(ticket) + } else { + r0 = ret.Error(0) + } + + return r0 +} + +// Database_UpdateTicketsWithoutGroup_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'UpdateTicketsWithoutGroup' +type Database_UpdateTicketsWithoutGroup_Call struct { + *mock.Call +} + +// UpdateTicketsWithoutGroup is a helper method to define mock.On call +// - ticket db.Tickets +func (_e *Database_Expecter) UpdateTicketsWithoutGroup(ticket interface{}) *Database_UpdateTicketsWithoutGroup_Call { + return &Database_UpdateTicketsWithoutGroup_Call{Call: _e.mock.On("UpdateTicketsWithoutGroup", ticket)} +} + +func (_c *Database_UpdateTicketsWithoutGroup_Call) Run(run func(ticket db.Tickets)) *Database_UpdateTicketsWithoutGroup_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(db.Tickets)) + }) + return _c +} + +func (_c *Database_UpdateTicketsWithoutGroup_Call) Return(_a0 error) *Database_UpdateTicketsWithoutGroup_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Database_UpdateTicketsWithoutGroup_Call) RunAndReturn(run func(db.Tickets) error) *Database_UpdateTicketsWithoutGroup_Call { + _c.Call.Return(run) + return _c +} + // UpdateTribe provides a mock function with given fields: uuid, u func (_m *Database) UpdateTribe(uuid string, u map[string]interface{}) bool { ret := _m.Called(uuid, u) @@ -9526,263 +9963,3 @@ func NewDatabase(t interface { return mock } - -// GetTicketsByPhaseUUID provides a mock function with given fields: featureUUID, phaseUUID -func (_m *Database) GetTicketsByPhaseUUID(featureUUID string, phaseUUID string) ([]db.Tickets, error) { - ret := _m.Called(featureUUID, phaseUUID) - - if len(ret) == 0 { - panic("no return value specified for GetTicketsByPhaseUUID") - } - - var r0 []db.Tickets - var r1 error - if rf, ok := ret.Get(0).(func(string, string) ([]db.Tickets, error)); ok { - return rf(featureUUID, phaseUUID) - } - if rf, ok := ret.Get(0).(func(string, string) []db.Tickets); ok { - r0 = rf(featureUUID, phaseUUID) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]db.Tickets) - } - } - - if rf, ok := ret.Get(1).(func(string, string) error); ok { - r1 = rf(featureUUID, phaseUUID) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type Database_GetTicketsByPhaseUUID_Call struct { - *mock.Call -} - -func (_e *Database_Expecter) GetTicketsByPhaseUUID(featureUUID interface{}, phaseUUID interface{}) *Database_GetTicketsByPhaseUUID_Call { - return &Database_GetTicketsByPhaseUUID_Call{Call: _e.mock.On("GetTicketsByPhaseUUID", featureUUID, phaseUUID)} -} - -func (_c *Database_GetTicketsByPhaseUUID_Call) Run(run func(featureUUID string, phaseUUID string)) *Database_GetTicketsByPhaseUUID_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string), args[1].(string)) - }) - return _c -} - -func (_c *Database_GetTicketsByPhaseUUID_Call) Return(_a0 []db.Tickets, _a1 error) *Database_GetTicketsByPhaseUUID_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *Database_GetTicketsByPhaseUUID_Call) RunAndReturn(run func(string, string) ([]db.Tickets, error)) *Database_GetTicketsByPhaseUUID_Call { - _c.Call.Return(run) - return _c -} - - -type Database_CreateOrEditCodeGraph_Call struct { - *mock.Call -} - -func (_e *Database_Expecter) CreateOrEditCodeGraph(m interface{}) *Database_CreateOrEditCodeGraph_Call { - return &Database_CreateOrEditCodeGraph_Call{Call: _e.mock.On("CreateOrEditCodeGraph", m)} -} - -func (_c *Database_CreateOrEditCodeGraph_Call) Run(run func(m db.WorkspaceCodeGraph)) *Database_CreateOrEditCodeGraph_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(db.WorkspaceCodeGraph)) - }) - return _c -} - -func (_c *Database_CreateOrEditCodeGraph_Call) Return(_a0 db.WorkspaceCodeGraph, _a1 error) *Database_CreateOrEditCodeGraph_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *Database_CreateOrEditCodeGraph_Call) RunAndReturn(run func(db.WorkspaceCodeGraph) (db.WorkspaceCodeGraph, error)) *Database_CreateOrEditCodeGraph_Call { - _c.Call.Return(run) - return _c -} - -// CreateOrEditCodeGraph provides a mock function with given fields: m -func (_m *Database) CreateOrEditCodeGraph(m db.WorkspaceCodeGraph) (db.WorkspaceCodeGraph, error) { - ret := _m.Called(m) - - if len(ret) == 0 { - panic("no return value specified for CreateOrEditCodeGraph") - } - - var r0 db.WorkspaceCodeGraph - var r1 error - if rf, ok := ret.Get(0).(func(db.WorkspaceCodeGraph) (db.WorkspaceCodeGraph, error)); ok { - return rf(m) - } - if rf, ok := ret.Get(0).(func(db.WorkspaceCodeGraph) db.WorkspaceCodeGraph); ok { - r0 = rf(m) - } else { - r0 = ret.Get(0).(db.WorkspaceCodeGraph) - } - - if rf, ok := ret.Get(1).(func(db.WorkspaceCodeGraph) error); ok { - r1 = rf(m) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type Database_GetCodeGraphByUUID_Call struct { - *mock.Call -} - -func (_e *Database_Expecter) GetCodeGraphByUUID(uuid interface{}) *Database_GetCodeGraphByUUID_Call { - return &Database_GetCodeGraphByUUID_Call{Call: _e.mock.On("GetCodeGraphByUUID", uuid)} -} - -func (_c *Database_GetCodeGraphByUUID_Call) Run(run func(uuid string)) *Database_GetCodeGraphByUUID_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) - }) - return _c -} - -func (_c *Database_GetCodeGraphByUUID_Call) Return(_a0 db.WorkspaceCodeGraph, _a1 error) *Database_GetCodeGraphByUUID_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *Database_GetCodeGraphByUUID_Call) RunAndReturn(run func(string) (db.WorkspaceCodeGraph, error)) *Database_GetCodeGraphByUUID_Call { - _c.Call.Return(run) - return _c -} - -// GetCodeGraphByUUID provides a mock function with given fields: uuid -func (_m *Database) GetCodeGraphByUUID(uuid string) (db.WorkspaceCodeGraph, error) { - ret := _m.Called(uuid) - - if len(ret) == 0 { - panic("no return value specified for GetCodeGraphByUUID") - } - - var r0 db.WorkspaceCodeGraph - var r1 error - if rf, ok := ret.Get(0).(func(string) (db.WorkspaceCodeGraph, error)); ok { - return rf(uuid) - } - if rf, ok := ret.Get(0).(func(string) db.WorkspaceCodeGraph); ok { - r0 = rf(uuid) - } else { - r0 = ret.Get(0).(db.WorkspaceCodeGraph) - } - - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(uuid) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type Database_GetCodeGraphsByWorkspaceUuid_Call struct { - *mock.Call -} - -func (_e *Database_Expecter) GetCodeGraphsByWorkspaceUuid(workspace_uuid interface{}) *Database_GetCodeGraphsByWorkspaceUuid_Call { - return &Database_GetCodeGraphsByWorkspaceUuid_Call{Call: _e.mock.On("GetCodeGraphsByWorkspaceUuid", workspace_uuid)} -} - -func (_c *Database_GetCodeGraphsByWorkspaceUuid_Call) Run(run func(workspace_uuid string)) *Database_GetCodeGraphsByWorkspaceUuid_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string)) - }) - return _c -} - -func (_c *Database_GetCodeGraphsByWorkspaceUuid_Call) Return(_a0 []db.WorkspaceCodeGraph, _a1 error) *Database_GetCodeGraphsByWorkspaceUuid_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *Database_GetCodeGraphsByWorkspaceUuid_Call) RunAndReturn(run func(string) ([]db.WorkspaceCodeGraph, error)) *Database_GetCodeGraphsByWorkspaceUuid_Call { - _c.Call.Return(run) - return _c -} - -// GetCodeGraphsByWorkspaceUuid provides a mock function with given fields: workspace_uuid -func (_m *Database) GetCodeGraphsByWorkspaceUuid(workspace_uuid string) ([]db.WorkspaceCodeGraph, error) { - ret := _m.Called(workspace_uuid) - - if len(ret) == 0 { - panic("no return value specified for GetCodeGraphsByWorkspaceUuid") - } - - var r0 []db.WorkspaceCodeGraph - var r1 error - if rf, ok := ret.Get(0).(func(string) ([]db.WorkspaceCodeGraph, error)); ok { - return rf(workspace_uuid) - } - if rf, ok := ret.Get(0).(func(string) []db.WorkspaceCodeGraph); ok { - r0 = rf(workspace_uuid) - } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([]db.WorkspaceCodeGraph) - } - } - - if rf, ok := ret.Get(1).(func(string) error); ok { - r1 = rf(workspace_uuid) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -type Database_DeleteCodeGraph_Call struct { - *mock.Call -} - -func (_e *Database_Expecter) DeleteCodeGraph(workspace_uuid interface{}, uuid interface{}) *Database_DeleteCodeGraph_Call { - return &Database_DeleteCodeGraph_Call{Call: _e.mock.On("DeleteCodeGraph", workspace_uuid, uuid)} -} - -func (_c *Database_DeleteCodeGraph_Call) Run(run func(workspace_uuid string, uuid string)) *Database_DeleteCodeGraph_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(string), args[1].(string)) - }) - return _c -} - -func (_c *Database_DeleteCodeGraph_Call) Return(_a0 error) *Database_DeleteCodeGraph_Call { - _c.Call.Return(_a0) - return _c -} - -func (_c *Database_DeleteCodeGraph_Call) RunAndReturn(run func(string, string) error) *Database_DeleteCodeGraph_Call { - _c.Call.Return(run) - return _c -} - -// DeleteCodeGraph provides a mock function with given fields: workspace_uuid, uuid -func (_m *Database) DeleteCodeGraph(workspace_uuid string, uuid string) error { - ret := _m.Called(workspace_uuid, uuid) - - if len(ret) == 0 { - panic("no return value specified for DeleteCodeGraph") - } - - var r0 error - if rf, ok := ret.Get(0).(func(string, string) error); ok { - r0 = rf(workspace_uuid, uuid) - } else { - r0 = ret.Error(0) - } - - return r0 -} \ No newline at end of file