forked from stakwork/sphinx-tribes
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into Add-Endpoints-for-Workspace-Repo
- Loading branch information
Showing
16 changed files
with
950 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
import { User, HostName, Workspaces, Repositories, Features } from '../support/objects/objects'; | ||
|
||
|
||
|
||
describe('Create Features for Workspace', () => { | ||
it('passes', () => { | ||
cy.upsertlogin(User).then(value => { | ||
for(let i = 0; i <= 2; i++) { | ||
cy.request({ | ||
method: 'POST', | ||
url: `${HostName}/features`, | ||
headers: { 'x-jwt': `${value}` }, | ||
body: Features[i] | ||
}).its('body').then(body => { | ||
expect(body).to.have.property('name').and.equal(Features[i].name.trim()); | ||
expect(body).to.have.property('brief').and.equal(Features[i].brief.trim()); | ||
expect(body).to.have.property('requirements').and.equal(Features[i].requirements.trim()); | ||
expect(body).to.have.property('architecture').and.equal(Features[i].architecture.trim()); | ||
}); | ||
} | ||
}) | ||
}) | ||
}) | ||
|
||
describe('Modify name for Feature', () => { | ||
it('passes', () => { | ||
cy.upsertlogin(User).then(value => { | ||
for(let i = 0; i <= 2; i++) { | ||
cy.request({ | ||
method: 'POST', | ||
url: `${HostName}/features`, | ||
headers: { 'x-jwt': `${value}` }, | ||
body: { | ||
uuid: Features[i].uuid, | ||
name: Features[i].name + "_addtext" | ||
} | ||
}).its('body').then(body => { | ||
expect(body).to.have.property('name').and.equal(Features[i].name.trim() + " _addtext"); | ||
expect(body).to.have.property('brief').and.equal(Features[i].brief.trim()); | ||
expect(body).to.have.property('requirements').and.equal(Features[i].requirements.trim()); | ||
expect(body).to.have.property('architecture').and.equal(Features[i].architecture.trim()); | ||
}); | ||
} | ||
}) | ||
}) | ||
}) | ||
|
||
describe('Modify brief for Feature', () => { | ||
it('passes', () => { | ||
cy.upsertlogin(User).then(value => { | ||
for(let i = 0; i <= 2; i++) { | ||
cy.request({ | ||
method: 'POST', | ||
url: `${HostName}/features`, | ||
headers: { 'x-jwt': `${value}` }, | ||
body: { | ||
uuid: Features[i].uuid, | ||
brief: Features[i].brief + "_addtext" | ||
} | ||
}).its('body').then(body => { | ||
expect(body).to.have.property('name').and.equal(Features[i].name.trim() + " _addtext"); | ||
expect(body).to.have.property('brief').and.equal(Features[i].brief.trim() + " _addtext"); | ||
expect(body).to.have.property('requirements').and.equal(Features[i].requirements.trim()); | ||
expect(body).to.have.property('architecture').and.equal(Features[i].architecture.trim()); | ||
}); | ||
} | ||
}) | ||
}) | ||
}) | ||
|
||
describe('Modify requirements for Feature', () => { | ||
it('passes', () => { | ||
cy.upsertlogin(User).then(value => { | ||
for(let i = 0; i <= 2; i++) { | ||
cy.request({ | ||
method: 'POST', | ||
url: `${HostName}/features`, | ||
headers: { 'x-jwt': `${value}` }, | ||
body: { | ||
uuid: Features[i].uuid, | ||
requirements: Features[i].requirements + "_addtext" | ||
} | ||
}).its('body').then(body => { | ||
expect(body).to.have.property('name').and.equal(Features[i].name.trim() + " _addtext"); | ||
expect(body).to.have.property('brief').and.equal(Features[i].brief.trim() + " _addtext"); | ||
expect(body).to.have.property('requirements').and.equal(Features[i].requirements.trim() + " _addtext"); | ||
expect(body).to.have.property('architecture').and.equal(Features[i].architecture.trim()); | ||
}); | ||
} | ||
}) | ||
}) | ||
}) | ||
|
||
describe('Modify architecture for Feature', () => { | ||
it('passes', () => { | ||
cy.upsertlogin(User).then(value => { | ||
for(let i = 0; i <= 2; i++) { | ||
cy.request({ | ||
method: 'POST', | ||
url: `${HostName}/features`, | ||
headers: { 'x-jwt': `${value}` }, | ||
body: { | ||
uuid: Features[i].uuid, | ||
architecture: Features[i].architecture + "_addtext" | ||
} | ||
}).its('body').then(body => { | ||
expect(body).to.have.property('name').and.equal(Features[i].name.trim() + " _addtext"); | ||
expect(body).to.have.property('brief').and.equal(Features[i].brief.trim() + " _addtext"); | ||
expect(body).to.have.property('requirements').and.equal(Features[i].requirements.trim() + " _addtext"); | ||
expect(body).to.have.property('architecture').and.equal(Features[i].architecture.trim() + " _addtext"); | ||
}); | ||
} | ||
}) | ||
}) | ||
}) | ||
|
||
|
||
describe('Get Features for Workspace', () => { | ||
it('passes', () => { | ||
cy.upsertlogin(User).then(value => { | ||
cy.request({ | ||
method: 'GET', | ||
url: `${HostName}/features/forworkspace/` + Features[0].workspace_uuid, | ||
headers: { 'x-jwt': `${ value }` }, | ||
body: {} | ||
}).then((resp) => { | ||
expect(resp.status).to.eq(200) | ||
for(let i = 0; i <= 2; i++) { | ||
expect(resp.body[i]).to.have.property('name', Features[i].name.trim() + " _addtext") | ||
expect(resp.body[i]).to.have.property('brief', Features[i].brief.trim() + " _addtext") | ||
expect(resp.body[i]).to.have.property('requirements', Features[i].requirements.trim() + " _addtext") | ||
expect(resp.body[i]).to.have.property('architecture', Features[i].architecture.trim() + " _addtext") | ||
} | ||
}) | ||
}) | ||
}) | ||
}) | ||
|
||
describe('Get Feature by uuid', () => { | ||
it('passes', () => { | ||
cy.upsertlogin(User).then(value => { | ||
for(let i = 0; i <= 2; i++) { | ||
cy.request({ | ||
method: 'GET', | ||
url: `${HostName}/features/` + Features[i].uuid, | ||
headers: { 'x-jwt': `${ value }` }, | ||
body: {} | ||
}).then((resp) => { | ||
expect(resp.status).to.eq(200) | ||
expect(resp.body).to.have.property('name', Features[i].name.trim() + " _addtext") | ||
expect(resp.body).to.have.property('brief', Features[i].brief.trim() + " _addtext") | ||
expect(resp.body).to.have.property('requirements', Features[i].requirements.trim() + " _addtext") | ||
expect(resp.body).to.have.property('architecture', Features[i].architecture.trim() + " _addtext") | ||
}) | ||
} | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package db | ||
|
||
import ( | ||
"strings" | ||
"time" | ||
) | ||
|
||
func (db database) GetFeaturesByWorkspaceUuid(uuid string) []WorkspaceFeatures { | ||
ms := []WorkspaceFeatures{} | ||
|
||
db.db.Model(&WorkspaceFeatures{}).Where("workspace_uuid = ?", uuid).Order("Created").Find(&ms) | ||
|
||
return ms | ||
} | ||
|
||
func (db database) GetFeatureByUuid(uuid string) WorkspaceFeatures { | ||
ms := WorkspaceFeatures{} | ||
|
||
db.db.Model(&WorkspaceFeatures{}).Where("uuid = ?", uuid).Find(&ms) | ||
|
||
return ms | ||
} | ||
|
||
func (db database) CreateOrEditFeature(m WorkspaceFeatures) (WorkspaceFeatures, error) { | ||
m.Name = strings.TrimSpace(m.Name) | ||
m.Brief = strings.TrimSpace(m.Brief) | ||
m.Requirements = strings.TrimSpace(m.Requirements) | ||
m.Architecture = strings.TrimSpace(m.Architecture) | ||
|
||
now := time.Now() | ||
m.Updated = &now | ||
|
||
if db.db.Model(&m).Where("uuid = ?", m.Uuid).Updates(&m).RowsAffected == 0 { | ||
m.Created = &now | ||
db.db.Create(&m) | ||
} | ||
|
||
db.db.Model(&WorkspaceFeatures{}).Where("uuid = ?", m.Uuid).Find(&m) | ||
|
||
return m, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.