This repository has been archived by the owner on Feb 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from heroku/pipeline-couplings-endpoints
Use new pipeline-couplings endpoints
- Loading branch information
Showing
10 changed files
with
208 additions
and
94 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
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
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,59 @@ | ||
const V3_HEADER = 'application/vnd.heroku+json; version=3'; | ||
const PIPELINES_HEADER = V3_HEADER + '.pipelines'; | ||
|
||
function getCoupling(heroku, app) { | ||
return heroku.request({ | ||
method: 'GET', | ||
path: `/apps/${app}/pipeline-couplings`, | ||
headers: { 'Accept': PIPELINES_HEADER } | ||
}); | ||
} | ||
|
||
function postCoupling(heroku, pipeline, app, stage) { | ||
return heroku.request({ | ||
method: 'POST', | ||
path: '/pipeline-couplings', | ||
body: {app: app, pipeline: pipeline, stage: stage}, | ||
headers: { 'Accept': PIPELINES_HEADER } | ||
}); | ||
} | ||
|
||
function patchCoupling(heroku, id, stage) { | ||
return heroku.request({ | ||
method: 'PATCH', | ||
path: `/pipeline-couplings/${id}`, | ||
body: {stage: stage}, | ||
headers: { 'Accept': PIPELINES_HEADER } | ||
}); | ||
} | ||
|
||
function deleteCoupling(heroku, id) { | ||
return heroku.request({ | ||
method: 'DELETE', | ||
path: `/pipeline-couplings/${id}`, | ||
headers: { 'Accept': PIPELINES_HEADER } | ||
}); | ||
} | ||
|
||
function createCoupling(heroku, pipeline, app, stage) { | ||
return postCoupling(heroku, pipeline.id, app, stage); | ||
} | ||
|
||
function updateCoupling(heroku, app, stage) { | ||
return getCoupling(heroku, app) | ||
.then(coupling => patchCoupling(heroku, coupling.id, stage)); | ||
} | ||
|
||
function removeCoupling(heroku, app) { | ||
return getCoupling(heroku, app) | ||
.then(coupling => deleteCoupling(heroku, coupling.id)); | ||
} | ||
|
||
exports.getCoupling = getCoupling; | ||
exports.postCoupling = postCoupling; | ||
exports.patchCoupling = patchCoupling; | ||
exports.deleteCoupling = deleteCoupling; | ||
|
||
exports.createCoupling = createCoupling; | ||
exports.updateCoupling = updateCoupling; | ||
exports.removeCoupling = removeCoupling; |
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,27 @@ | ||
'use strict'; | ||
|
||
const cli = require('heroku-cli-util'); | ||
const nock = require('nock'); | ||
const cmd = require('../../../commands/pipelines/remove'); | ||
|
||
describe('pipelines:remove', () => { | ||
beforeEach(() => cli.mockConsole()); | ||
|
||
it('displays the right messages', () => { | ||
const app = 'example'; | ||
const id = '0123'; | ||
|
||
const pipeline_coupling = { id, stage: 'production' }; | ||
|
||
nock('https://api.heroku.com') | ||
.get(`/apps/${app}/pipeline-couplings`) | ||
.reply(200, pipeline_coupling); | ||
|
||
nock('https://api.heroku.com') | ||
.delete(`/pipeline-couplings/${id}`) | ||
.reply(200, pipeline_coupling); | ||
|
||
return cmd.run({ app }) | ||
.then(() => cli.stderr.should.contain(`Removing ${app}... done`)); | ||
}); | ||
}); |
Oops, something went wrong.