add support for DELETE /builds/:repo/:pr
Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
parent
56529f3fe1
commit
dfe95c0e2b
|
@ -55,6 +55,12 @@ const App = ({ghc, schema}) => {
|
|||
ctx.body = {count: builds.length, builds}
|
||||
})
|
||||
|
||||
/* drop builds for repo+pr */
|
||||
router.delete('/builds/:repo/:pr', async (ctx) => {
|
||||
const rval = await ghc.db.removeBuilds(ctx.params)
|
||||
ctx.body = {}
|
||||
})
|
||||
|
||||
/* list all managed comments */
|
||||
router.get('/comments', async (ctx) => {
|
||||
const comments = await ghc.db.getComments()
|
||||
|
|
|
@ -65,13 +65,18 @@ class Builds {
|
|||
})
|
||||
}
|
||||
|
||||
async removeBuilds ({repo, pr}) {
|
||||
log.info(`Removing build for ${repo}/PR-${pr}`)
|
||||
return await this.builds.findAndRemove({repo, pr})
|
||||
}
|
||||
|
||||
async addBuild ({repo, pr, build}) {
|
||||
log.info(`Storing build for PR-${pr}: #${build.id} for ${build.platform}`)
|
||||
log.info(`Storing build for ${repo}/PR-${pr}: #${build.id} for ${build.platform}`)
|
||||
return await this.builds.insert({repo, pr, ...build})
|
||||
}
|
||||
|
||||
async addComment ({repo, pr, comment_id}) {
|
||||
log.info(`Storing comment for PR-${pr}: ${comment_id}`)
|
||||
log.info(`Storing comment for ${repo}/PR-${pr}: ${comment_id}`)
|
||||
return await this.comments.insert({repo, pr, comment_id})
|
||||
}
|
||||
|
||||
|
|
12
test/app.js
12
test/app.js
|
@ -66,6 +66,18 @@ describe('App', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('DELETE /builds/:repo/:pr', () => {
|
||||
it('should delete all matching builds', async () => {
|
||||
const resp = await request(app.callback())
|
||||
.delete('/builds/REPO-1/PR-1')
|
||||
expect(resp.body).to.eql({})
|
||||
expect(resp.status).to.eq(200)
|
||||
expect(ghc.db.removeBuilds).calledOnceWith({
|
||||
repo: 'REPO-1', pr: 'PR-1',
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('POST /builds/:repo/:pr/refresh', () => {
|
||||
it('should update github comment', async () => {
|
||||
const resp = await request(app.callback())
|
||||
|
|
Loading…
Reference in New Issue