diff --git a/cypress/e2e/02_repositories.cy.ts b/cypress/e2e/02_repositories.cy.ts index dba204270..6d70aaf24 100644 --- a/cypress/e2e/02_repositories.cy.ts +++ b/cypress/e2e/02_repositories.cy.ts @@ -1,10 +1,10 @@ -import { User, HostName, Workspaces, Repositories } from '../support/objects/objects'; +import { User, HostName, Repositories } from '../support/objects/objects'; describe('Create Repositories for Workspace', () => { it('passes', () => { cy.upsertlogin(User).then(value => { - for(let i = 0; i <= 1; i++) { + for (let i = 0; i <= 1; i++) { cy.request({ method: 'POST', url: `${HostName}/workspaces/repositories`, @@ -13,7 +13,49 @@ describe('Create Repositories for Workspace', () => { }).its('body').then(body => { expect(body).to.have.property('name').and.equal(Repositories[i].name.trim()); expect(body).to.have.property('url').and.equal(Repositories[i].url.trim()); - }); + }); + } + }) + }) +}) + +describe('Modify Repository name for Workspace', () => { + it('passes', () => { + cy.upsertlogin(User).then(value => { + for (let i = 0; i <= 1; i++) { + cy.request({ + method: 'POST', + url: `${HostName}/workspaces/repositories`, + headers: { 'x-jwt': `${value}` }, + body: { + uuid: Repositories[i].uuid, + name: Repositories[i].name.trim() + "_addText" + } + }).its('body').then(body => { + expect(body).to.have.property('name').and.equal(Repositories[i].name.trim() + "_addText"); + expect(body).to.have.property('url').and.equal(Repositories[i].url.trim()); + }); + } + }) + }) +}) + +describe('Modify Repository url for Workspace', () => { + it('passes', () => { + cy.upsertlogin(User).then(value => { + for (let i = 0; i <= 1; i++) { + cy.request({ + method: 'POST', + url: `${HostName}/workspaces/repositories`, + headers: { 'x-jwt': `${value}` }, + body: { + uuid: Repositories[i].uuid, + url: Repositories[i].url.trim() + "_addText" + } + }).its('body').then(body => { + expect(body).to.have.property('name').and.equal(Repositories[i].name.trim() + "_addText"); + expect(body).to.have.property('url').and.equal(Repositories[i].url.trim() + "_addText"); + }); } }) }) @@ -21,20 +63,69 @@ describe('Create Repositories for Workspace', () => { describe('Check Repositories Values', () => { + it('passes', () => { + cy.upsertlogin(User).then(value => { + for (let i = 0; i <= 1; i++) { + cy.request({ + method: 'GET', + url: `${HostName}/workspaces/repositories/` + Repositories[i].workspace_uuid, + headers: { 'x-jwt': `${value}` }, + body: {} + }).then((resp) => { + expect(resp.status).to.eq(200) + expect(resp.body[i]).to.have.property('name', Repositories[i].name.trim() + "_addText") + expect(resp.body[i]).to.have.property('url', Repositories[i].url.trim() + "_addText") + }) + } + }) + }) +}) + +describe('Get repository by uuid', () => { + it('passes', () => { + cy.upsertlogin(User).then(value => { + for (let i = 0; i <= 1; i++) { + cy.request({ + method: 'GET', + url: `${HostName}/workspaces/${Repositories[i].workspace_uuid}/repository/${Repositories[i].uuid}`, + headers: { 'x-jwt': `${value}` } + }).then((resp) => { + expect(resp.status).to.eq(200) + expect(resp.body).to.have.property('name', Repositories[i].name.trim() + "_addText") + expect(resp.body).to.have.property('url', Repositories[i].url.trim() + "_addText") + }) + } + }) + }) +}) + +describe('Delete repository by uuid', () => { it('passes', () => { cy.upsertlogin(User).then(value => { cy.request({ - method: 'GET', - url: `${HostName}/workspaces/repositories/` + Repositories[0].workspace_uuid, - headers: { 'x-jwt': `${ value }` }, - body: {} + method: 'DELETE', + url: `${HostName}/workspaces/${Repositories[0].workspace_uuid}/repository/${Repositories[0].uuid}`, + headers: { 'x-jwt': `${value}` }, + body: {} }).then((resp) => { expect(resp.status).to.eq(200) - expect(resp.body[0]).to.have.property('name', Repositories[0].name.trim()) - expect(resp.body[0]).to.have.property('url', Repositories[0].url.trim()) - expect(resp.body[1]).to.have.property('name', Repositories[1].name.trim()) - expect(resp.body[1]).to.have.property('url', Repositories[1].url.trim()) }) }) }) }) + +describe('Check delete by uuid', () => { + it('passes', () => { + cy.upsertlogin(User).then(value => { + cy.request({ + method: 'GET', + url: `${HostName}/workspaces/${Repositories[0].workspace_uuid}/repository/${Repositories[0].uuid}`, + headers: { 'x-jwt': `${value}` }, + body: {}, + failOnStatusCode: false + }).then((resp) => { + expect(resp.status).to.eq(404); + }) + }) + }) +}) \ No newline at end of file diff --git a/cypress/e2e/07_add_bounty_to_phase.cy.ts b/cypress/e2e/07_add_bounty_to_phase.cy.ts new file mode 100644 index 000000000..aa66a2736 --- /dev/null +++ b/cypress/e2e/07_add_bounty_to_phase.cy.ts @@ -0,0 +1,21 @@ +import { User, HostName, Bounties } from '../support/objects/objects'; + + +describe('Create Bounty', () => { + it('passes', () => { + cy.upsertlogin(User).then(value => { + for (let i = 0; i <= 2; i++) { + cy.request({ + method: 'POST', + url: `${HostName}/gobounties/`, + headers: { 'x-jwt': `${value}` }, + body: Bounties[i], + failOnStatusCode: false + })//.its('body').should('have.property', 'id', Workspaces[i].name.trim()) + .then(value => { + console.log(value); + }); + } + }) + }) +}) \ No newline at end of file diff --git a/cypress/support/objects/objects.ts b/cypress/support/objects/objects.ts index 973ab70fe..def50f67e 100644 --- a/cypress/support/objects/objects.ts +++ b/cypress/support/objects/objects.ts @@ -141,4 +141,39 @@ export const Phases = [ { uuid: 'com1msgn1e4a0ts5kls0', feature_uuid: 'com1kson1e49th88dbg0', name: ' MVP ', priority: 0 }, { uuid: 'com1mvgn1e4a1879uiv0', feature_uuid: 'com1kson1e49th88dbg0', name: ' Phase 2 ', priority: 1 }, { uuid: 'com1n2gn1e4a1i8p60p0', feature_uuid: 'com1kson1e49th88dbg0', name: ' Phase 3 ', priority: 2 }, -]; \ No newline at end of file +]; + +export const Bounties = [ + { + id: 0, + owner_id: '', + paid: false, + show: true, + completed: false, + type: '', //TODO find out more + award: '', //TODO find out more + assigned_hours: 2, + bounty_expires: '', + commitment_fee: 0, //TODO find out more + price: 21, + title: 'Add Features endpoints', + tribe: '', + assignee: '', + ticket_url: '', + workspace_id: Workspaces[0], + description: '', + wanted_type: '', //TODO find out more + deliverables: '', //TODO find out more + github_description: '', + one_sentence_summary: '', + estimated_session_length: '', //TODO find out more + estimated_completion_date: '2024-05-31', + created: '', + updated: '', + assigned_date: '', + completion_date: '', + mark_as_paid_date: '', + paid_date: '', + coding_languages: ['Golang'], + }, +] \ No newline at end of file diff --git a/db/interface.go b/db/interface.go index 4b4585b99..e5b31a951 100644 --- a/db/interface.go +++ b/db/interface.go @@ -140,8 +140,10 @@ type Database interface { PersonUniqueNameFromName(name string) (string, error) ProcessAlerts(p Person) UserHasAccess(pubKeyFromAuth string, uuid string, role string) bool - CreateWorkspaceRepository(m WorkspaceRepositories) (WorkspaceRepositories, error) + CreateOrEditWorkspaceRepository(m WorkspaceRepositories) (WorkspaceRepositories, error) GetWorkspaceRepositorByWorkspaceUuid(uuid string) []WorkspaceRepositories + GetWorkspaceRepoByWorkspaceUuidAndRepoUuid(workspace_uuid string, uuid string) (WorkspaceRepositories, error) + DeleteWorkspaceRepository(workspace_uuid string, uuid string) bool CreateOrEditFeature(m WorkspaceFeatures) (WorkspaceFeatures, error) GetFeaturesByWorkspaceUuid(uuid string, r *http.Request) []WorkspaceFeatures GetWorkspaceFeaturesCount(uuid string) int64 diff --git a/db/structs.go b/db/structs.go index 6988a5511..7e1aede2d 100644 --- a/db/structs.go +++ b/db/structs.go @@ -571,6 +571,7 @@ type WorkspaceFeatures struct { Brief string `json:"brief"` Requirements string `json:"requirements"` Architecture string `json:"architecture"` + Url string `json:"url"` Created *time.Time `json:"created"` Updated *time.Time `json:"updated"` CreatedBy string `json:"created_by"` diff --git a/db/workspaces.go b/db/workspaces.go index f11c298c8..89064d92a 100644 --- a/db/workspaces.go +++ b/db/workspaces.go @@ -58,7 +58,7 @@ func (db database) CreateOrEditWorkspace(m Workspace) (Workspace, error) { return m, nil } -func (db database) CreateWorkspaceRepository(m WorkspaceRepositories) (WorkspaceRepositories, error) { +func (db database) CreateOrEditWorkspaceRepository(m WorkspaceRepositories) (WorkspaceRepositories, error) { m.Name = strings.TrimSpace(m.Name) m.Url = strings.TrimSpace(m.Url) @@ -70,6 +70,8 @@ func (db database) CreateWorkspaceRepository(m WorkspaceRepositories) (Workspace db.db.Create(&m) } + db.db.Model(&WorkspaceRepositories{}).Where("uuid = ?", m.Uuid).Find(&m) + return m, nil } @@ -81,6 +83,22 @@ func (db database) GetWorkspaceRepositorByWorkspaceUuid(uuid string) []Workspace return ms } +func (db database) GetWorkspaceRepoByWorkspaceUuidAndRepoUuid(workspace_uuid string, uuid string) (WorkspaceRepositories, error) { + var ms WorkspaceRepositories + + result := db.db.Model(&WorkspaceRepositories{}).Where("workspace_uuid = ?", workspace_uuid).Where("uuid = ?", uuid).Find(&ms) + if result.RowsAffected == 0 { + return ms, fmt.Errorf("workspace repository not found") + } + + return ms, nil +} + +func (db database) DeleteWorkspaceRepository(workspace_uuid string, uuid string) bool { + db.db.Where("workspace_uuid = ?", workspace_uuid).Where("uuid = ?", uuid).Delete(&WorkspaceRepositories{}) + return true +} + func (db database) GetWorkspaceUsers(uuid string) ([]WorkspaceUsersData, error) { ms := []WorkspaceUsersData{} diff --git a/handlers/workspaces.go b/handlers/workspaces.go index 9cdd10dd9..0fa62d621 100644 --- a/handlers/workspaces.go +++ b/handlers/workspaces.go @@ -783,7 +783,7 @@ func (oh *workspaceHandler) UpdateWorkspace(w http.ResponseWriter, r *http.Reque json.NewEncoder(w).Encode(p) } -func (oh *workspaceHandler) CreateWorkspaceRepository(w http.ResponseWriter, r *http.Request) { +func (oh *workspaceHandler) CreateOrEditWorkspaceRepository(w http.ResponseWriter, r *http.Request) { ctx := r.Context() pubKeyFromAuth, _ := ctx.Value(auth.ContextKey).(string) if pubKeyFromAuth == "" { @@ -803,7 +803,12 @@ func (oh *workspaceHandler) CreateWorkspaceRepository(w http.ResponseWriter, r * return } - workspaceRepo.CreatedBy = pubKeyFromAuth + if len(workspaceRepo.Uuid) == 0 { + workspaceRepo.Uuid = xid.New().String() + workspaceRepo.CreatedBy = pubKeyFromAuth + } + + workspaceRepo.UpdatedBy = pubKeyFromAuth if workspaceRepo.Uuid == "" { workspaceRepo.Uuid = xid.New().String() @@ -820,15 +825,7 @@ func (oh *workspaceHandler) CreateWorkspaceRepository(w http.ResponseWriter, r * return } - // Check if workspace exists - workpace := oh.db.GetWorkspaceByUuid(workspaceRepo.WorkspaceUuid) - if workpace.Uuid != workspaceRepo.WorkspaceUuid { - w.WriteHeader(http.StatusUnauthorized) - json.NewEncoder(w).Encode("Workspace does not exists") - return - } - - p, err := oh.db.CreateWorkspaceRepository(workspaceRepo) + p, err := oh.db.CreateOrEditWorkspaceRepository(workspaceRepo) if err != nil { w.WriteHeader(http.StatusBadRequest) return @@ -853,3 +850,45 @@ func (oh *workspaceHandler) GetWorkspaceRepositorByWorkspaceUuid(w http.Response w.WriteHeader(http.StatusOK) json.NewEncoder(w).Encode(workspaceFeatures) } + +func (oh *workspaceHandler) GetWorkspaceRepoByWorkspaceUuidAndRepoUuid(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + pubKeyFromAuth, _ := ctx.Value(auth.ContextKey).(string) + if pubKeyFromAuth == "" { + fmt.Println("no pubkey from auth") + w.WriteHeader(http.StatusUnauthorized) + return + } + + workspace_uuid := chi.URLParam(r, "workspace_uuid") + uuid := chi.URLParam(r, "uuid") + WorkspaceRepository, err := oh.db.GetWorkspaceRepoByWorkspaceUuidAndRepoUuid(workspace_uuid, uuid) + if err != nil { + fmt.Println("workspace repository not found:", err) + w.WriteHeader(http.StatusNotFound) + json.NewEncoder(w).Encode(map[string]string{"error": "Repository not found"}) + return + } + + w.Header().Set("Content-Type", "application/json") + w.WriteHeader(http.StatusOK) + json.NewEncoder(w).Encode(WorkspaceRepository) +} + +func (oh *workspaceHandler) DeleteWorkspaceRepository(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + pubKeyFromAuth, _ := ctx.Value(auth.ContextKey).(string) + + if pubKeyFromAuth == "" { + fmt.Println("no pubkey from auth") + w.WriteHeader(http.StatusUnauthorized) + return + } + + workspace_uuid := chi.URLParam(r, "workspace_uuid") + uuid := chi.URLParam(r, "uuid") + + oh.db.DeleteWorkspaceRepository(workspace_uuid, uuid) + + w.WriteHeader(http.StatusOK) +} diff --git a/mocks/Database.go b/mocks/Database.go index 3028b31a2..b5834fe28 100644 --- a/mocks/Database.go +++ b/mocks/Database.go @@ -1266,6 +1266,62 @@ func (_c *Database_CreateOrEditWorkspace_Call) RunAndReturn(run func(db.Workspac return _c } +// CreateOrEditWorkspaceRepository provides a mock function with given fields: m +func (_m *Database) CreateOrEditWorkspaceRepository(m db.WorkspaceRepositories) (db.WorkspaceRepositories, error) { + ret := _m.Called(m) + + if len(ret) == 0 { + panic("no return value specified for CreateOrEditWorkspaceRepository") + } + + var r0 db.WorkspaceRepositories + var r1 error + if rf, ok := ret.Get(0).(func(db.WorkspaceRepositories) (db.WorkspaceRepositories, error)); ok { + return rf(m) + } + if rf, ok := ret.Get(0).(func(db.WorkspaceRepositories) db.WorkspaceRepositories); ok { + r0 = rf(m) + } else { + r0 = ret.Get(0).(db.WorkspaceRepositories) + } + + if rf, ok := ret.Get(1).(func(db.WorkspaceRepositories) error); ok { + r1 = rf(m) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Database_CreateOrEditWorkspaceRepository_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateOrEditWorkspaceRepository' +type Database_CreateOrEditWorkspaceRepository_Call struct { + *mock.Call +} + +// CreateOrEditWorkspaceRepository is a helper method to define mock.On call +// - m db.WorkspaceRepositories +func (_e *Database_Expecter) CreateOrEditWorkspaceRepository(m interface{}) *Database_CreateOrEditWorkspaceRepository_Call { + return &Database_CreateOrEditWorkspaceRepository_Call{Call: _e.mock.On("CreateOrEditWorkspaceRepository", m)} +} + +func (_c *Database_CreateOrEditWorkspaceRepository_Call) Run(run func(m db.WorkspaceRepositories)) *Database_CreateOrEditWorkspaceRepository_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(db.WorkspaceRepositories)) + }) + return _c +} + +func (_c *Database_CreateOrEditWorkspaceRepository_Call) Return(_a0 db.WorkspaceRepositories, _a1 error) *Database_CreateOrEditWorkspaceRepository_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Database_CreateOrEditWorkspaceRepository_Call) RunAndReturn(run func(db.WorkspaceRepositories) (db.WorkspaceRepositories, error)) *Database_CreateOrEditWorkspaceRepository_Call { + _c.Call.Return(run) + return _c +} + // CreateUserRoles provides a mock function with given fields: roles, uuid, pubkey func (_m *Database) CreateUserRoles(roles []db.WorkspaceUserRoles, uuid string, pubkey string) []db.WorkspaceUserRoles { ret := _m.Called(roles, uuid, pubkey) @@ -1362,62 +1418,6 @@ func (_c *Database_CreateWorkspaceBudget_Call) RunAndReturn(run func(db.NewBount return _c } -// CreateWorkspaceRepository provides a mock function with given fields: m -func (_m *Database) CreateWorkspaceRepository(m db.WorkspaceRepositories) (db.WorkspaceRepositories, error) { - ret := _m.Called(m) - - if len(ret) == 0 { - panic("no return value specified for CreateWorkspaceRepository") - } - - var r0 db.WorkspaceRepositories - var r1 error - if rf, ok := ret.Get(0).(func(db.WorkspaceRepositories) (db.WorkspaceRepositories, error)); ok { - return rf(m) - } - if rf, ok := ret.Get(0).(func(db.WorkspaceRepositories) db.WorkspaceRepositories); ok { - r0 = rf(m) - } else { - r0 = ret.Get(0).(db.WorkspaceRepositories) - } - - if rf, ok := ret.Get(1).(func(db.WorkspaceRepositories) error); ok { - r1 = rf(m) - } else { - r1 = ret.Error(1) - } - - return r0, r1 -} - -// Database_CreateWorkspaceRepository_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'CreateWorkspaceRepository' -type Database_CreateWorkspaceRepository_Call struct { - *mock.Call -} - -// CreateWorkspaceRepository is a helper method to define mock.On call -// - m db.WorkspaceRepositories -func (_e *Database_Expecter) CreateWorkspaceRepository(m interface{}) *Database_CreateWorkspaceRepository_Call { - return &Database_CreateWorkspaceRepository_Call{Call: _e.mock.On("CreateWorkspaceRepository", m)} -} - -func (_c *Database_CreateWorkspaceRepository_Call) Run(run func(m db.WorkspaceRepositories)) *Database_CreateWorkspaceRepository_Call { - _c.Call.Run(func(args mock.Arguments) { - run(args[0].(db.WorkspaceRepositories)) - }) - return _c -} - -func (_c *Database_CreateWorkspaceRepository_Call) Return(_a0 db.WorkspaceRepositories, _a1 error) *Database_CreateWorkspaceRepository_Call { - _c.Call.Return(_a0, _a1) - return _c -} - -func (_c *Database_CreateWorkspaceRepository_Call) RunAndReturn(run func(db.WorkspaceRepositories) (db.WorkspaceRepositories, error)) *Database_CreateWorkspaceRepository_Call { - _c.Call.Return(run) - return _c -} - // CreateWorkspaceUser provides a mock function with given fields: orgUser func (_m *Database) CreateWorkspaceUser(orgUser db.WorkspaceUsers) db.WorkspaceUsers { ret := _m.Called(orgUser) @@ -1707,6 +1707,53 @@ func (_c *Database_DeleteUserInvoiceData_Call) RunAndReturn(run func(string) db. return _c } +// DeleteWorkspaceRepository provides a mock function with given fields: workspace_uuid, uuid +func (_m *Database) DeleteWorkspaceRepository(workspace_uuid string, uuid string) bool { + ret := _m.Called(workspace_uuid, uuid) + + if len(ret) == 0 { + panic("no return value specified for DeleteWorkspaceRepository") + } + + var r0 bool + if rf, ok := ret.Get(0).(func(string, string) bool); ok { + r0 = rf(workspace_uuid, uuid) + } else { + r0 = ret.Get(0).(bool) + } + + return r0 +} + +// Database_DeleteWorkspaceRepository_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'DeleteWorkspaceRepository' +type Database_DeleteWorkspaceRepository_Call struct { + *mock.Call +} + +// DeleteWorkspaceRepository is a helper method to define mock.On call +// - workspace_uuid string +// - uuid string +func (_e *Database_Expecter) DeleteWorkspaceRepository(workspace_uuid interface{}, uuid interface{}) *Database_DeleteWorkspaceRepository_Call { + return &Database_DeleteWorkspaceRepository_Call{Call: _e.mock.On("DeleteWorkspaceRepository", workspace_uuid, uuid)} +} + +func (_c *Database_DeleteWorkspaceRepository_Call) Run(run func(workspace_uuid string, uuid string)) *Database_DeleteWorkspaceRepository_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(string)) + }) + return _c +} + +func (_c *Database_DeleteWorkspaceRepository_Call) Return(_a0 bool) *Database_DeleteWorkspaceRepository_Call { + _c.Call.Return(_a0) + return _c +} + +func (_c *Database_DeleteWorkspaceRepository_Call) RunAndReturn(run func(string, string) bool) *Database_DeleteWorkspaceRepository_Call { + _c.Call.Return(run) + return _c +} + // DeleteWorkspaceUser provides a mock function with given fields: orgUser, org func (_m *Database) DeleteWorkspaceUser(orgUser db.WorkspaceUsersData, org string) db.WorkspaceUsersData { ret := _m.Called(orgUser, org) @@ -5427,6 +5474,63 @@ func (_c *Database_GetWorkspaceInvoicesCount_Call) RunAndReturn(run func(string) return _c } +// GetWorkspaceRepoByWorkspaceUuidAndRepoUuid provides a mock function with given fields: workspace_uuid, uuid +func (_m *Database) GetWorkspaceRepoByWorkspaceUuidAndRepoUuid(workspace_uuid string, uuid string) (db.WorkspaceRepositories, error) { + ret := _m.Called(workspace_uuid, uuid) + + if len(ret) == 0 { + panic("no return value specified for GetWorkspaceRepoByWorkspaceUuidAndRepoUuid") + } + + var r0 db.WorkspaceRepositories + var r1 error + if rf, ok := ret.Get(0).(func(string, string) (db.WorkspaceRepositories, error)); ok { + return rf(workspace_uuid, uuid) + } + if rf, ok := ret.Get(0).(func(string, string) db.WorkspaceRepositories); ok { + r0 = rf(workspace_uuid, uuid) + } else { + r0 = ret.Get(0).(db.WorkspaceRepositories) + } + + if rf, ok := ret.Get(1).(func(string, string) error); ok { + r1 = rf(workspace_uuid, uuid) + } else { + r1 = ret.Error(1) + } + + return r0, r1 +} + +// Database_GetWorkspaceRepoByWorkspaceUuidAndRepoUuid_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetWorkspaceRepoByWorkspaceUuidAndRepoUuid' +type Database_GetWorkspaceRepoByWorkspaceUuidAndRepoUuid_Call struct { + *mock.Call +} + +// GetWorkspaceRepoByWorkspaceUuidAndRepoUuid is a helper method to define mock.On call +// - workspace_uuid string +// - uuid string +func (_e *Database_Expecter) GetWorkspaceRepoByWorkspaceUuidAndRepoUuid(workspace_uuid interface{}, uuid interface{}) *Database_GetWorkspaceRepoByWorkspaceUuidAndRepoUuid_Call { + return &Database_GetWorkspaceRepoByWorkspaceUuidAndRepoUuid_Call{Call: _e.mock.On("GetWorkspaceRepoByWorkspaceUuidAndRepoUuid", workspace_uuid, uuid)} +} + +func (_c *Database_GetWorkspaceRepoByWorkspaceUuidAndRepoUuid_Call) Run(run func(workspace_uuid string, uuid string)) *Database_GetWorkspaceRepoByWorkspaceUuidAndRepoUuid_Call { + _c.Call.Run(func(args mock.Arguments) { + run(args[0].(string), args[1].(string)) + }) + return _c +} + +func (_c *Database_GetWorkspaceRepoByWorkspaceUuidAndRepoUuid_Call) Return(_a0 db.WorkspaceRepositories, _a1 error) *Database_GetWorkspaceRepoByWorkspaceUuidAndRepoUuid_Call { + _c.Call.Return(_a0, _a1) + return _c +} + +func (_c *Database_GetWorkspaceRepoByWorkspaceUuidAndRepoUuid_Call) RunAndReturn(run func(string, string) (db.WorkspaceRepositories, error)) *Database_GetWorkspaceRepoByWorkspaceUuidAndRepoUuid_Call { + _c.Call.Return(run) + return _c +} + // GetWorkspaceRepositorByWorkspaceUuid provides a mock function with given fields: uuid func (_m *Database) GetWorkspaceRepositorByWorkspaceUuid(uuid string) []db.WorkspaceRepositories { ret := _m.Called(uuid) diff --git a/routes/workspaces.go b/routes/workspaces.go index d02c6e956..9aa59d0af 100644 --- a/routes/workspaces.go +++ b/routes/workspaces.go @@ -43,8 +43,10 @@ func WorkspaceRoutes() chi.Router { r.Post("/tactics", workspaceHandlers.UpdateWorkspace) r.Post("/schematicurl", workspaceHandlers.UpdateWorkspace) - r.Post("/repositories", workspaceHandlers.CreateWorkspaceRepository) + r.Post("/repositories", workspaceHandlers.CreateOrEditWorkspaceRepository) r.Get("/repositories/{uuid}", workspaceHandlers.GetWorkspaceRepositorByWorkspaceUuid) + r.Get("/{workspace_uuid}/repository/{uuid}", workspaceHandlers.GetWorkspaceRepoByWorkspaceUuidAndRepoUuid) + r.Delete("/{workspace_uuid}/repository/{uuid}", workspaceHandlers.DeleteWorkspaceRepository) }) return r }