-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update release commands to work with eligibility attribute. (#3081)
* Update release commands to work with eligibility attribute. * Add eligibility info to release info. * fix test
- Loading branch information
Showing
8 changed files
with
181 additions
and
54 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 |
---|---|---|
|
@@ -107,11 +107,6 @@ describe('releases', function () { | |
}, | ||
}, | ||
] | ||
const slug = { | ||
process_types: { | ||
release: 'bundle exec rake db:migrate', | ||
}, | ||
} | ||
|
||
it('shows releases', async function () { | ||
process.stdout.isTTY = true | ||
|
@@ -134,7 +129,7 @@ describe('releases', function () { | |
v37 first commit [email protected] 2015/11/18 01:36:38 +0000 | ||
`) | ||
assertLineWidths(stdout.output, 80) | ||
// expect(stderr.output).to.equal('') | ||
expect(stderr.output).to.equal('') | ||
api.done() | ||
}) | ||
|
||
|
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 |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import {stdout, stderr} from 'stdout-stderr' | ||
import {stdout} from 'stdout-stderr' | ||
import Cmd from '../../../../src/commands/releases/info' | ||
import runCommand from '../../../helpers/runCommand' | ||
import * as nock from 'nock' | ||
import {expect} from 'chai' | ||
import expectOutput from '../../../helpers/utils/expectOutput' | ||
import heredoc from 'tsheredoc' | ||
|
||
const d = new Date(2000, 1, 1) | ||
describe('releases:info', function () { | ||
|
@@ -14,98 +16,200 @@ describe('releases:info', function () { | |
description: 'something changed', | ||
user: { | ||
email: '[email protected]', | ||
}, created_at: d, version: 10, addon_plan_names: ['addon1', 'addon2'], | ||
}, created_at: d, | ||
version: 10, | ||
eligible_for_rollback: true, | ||
addon_plan_names: ['addon1', 'addon2'], | ||
} | ||
|
||
const configVars = {FOO: 'foo', BAR: 'bar'} | ||
|
||
it('shows most recent release info', function () { | ||
const api = nock('https://api.heroku.com:443') | ||
it('shows most recent release info', async function () { | ||
nock('https://api.heroku.com') | ||
.get('/apps/myapp/releases') | ||
.reply(200, [release]) | ||
.get('/apps/myapp/releases/10/config-vars') | ||
.reply(200, configVars) | ||
return runCommand(Cmd, [ | ||
await runCommand(Cmd, [ | ||
'--app', | ||
'myapp', | ||
]) | ||
.then(() => expect(stdout.output).to.equal(`=== Release v10\n\nAdd-ons: addon1\n addon2\nBy: [email protected]\nChange: something changed\nWhen: ${d.toISOString()}\n\n=== v10 Config vars\n\nBAR: bar\nFOO: foo\n`)) | ||
.then(() => api.done()) | ||
expectOutput(stdout.output, heredoc(` | ||
=== Release v10 | ||
Add-ons: addon1 | ||
addon2 | ||
By: [email protected] | ||
Change: something changed | ||
Eligible for Rollback?: Yes | ||
When: ${d.toISOString()} | ||
=== v10 Config vars | ||
BAR: bar | ||
FOO: foo | ||
`)) | ||
}) | ||
|
||
it('shows most recent release info config vars as shell', function () { | ||
const api = nock('https://api.heroku.com:443') | ||
it('shows most recent release info config vars as shell', async function () { | ||
nock('https://api.heroku.com') | ||
.get('/apps/myapp/releases') | ||
.reply(200, [release]) | ||
.get('/apps/myapp/releases/10/config-vars') | ||
.reply(200, configVars) | ||
return runCommand(Cmd, [ | ||
await runCommand(Cmd, [ | ||
'--app', | ||
'myapp', | ||
'--shell', | ||
]) | ||
.then(() => expect(stdout.output).to.equal(`=== Release v10\n\nAdd-ons: addon1\n addon2\nBy: [email protected]\nChange: something changed\nWhen: ${d.toISOString()}\n\n=== v10 Config vars\n\nFOO=foo\nBAR=bar\n`)) | ||
.then(() => api.done()) | ||
expectOutput(stdout.output, heredoc(` | ||
=== Release v10 | ||
Add-ons: addon1 | ||
addon2 | ||
By: [email protected] | ||
Change: something changed | ||
Eligible for Rollback?: Yes | ||
When: ${d.toISOString()} | ||
=== v10 Config vars | ||
FOO=foo | ||
BAR=bar | ||
`)) | ||
}) | ||
|
||
it('shows release info by id', function () { | ||
const api = nock('https://api.heroku.com:443') | ||
it('shows release info by id', async function () { | ||
nock('https://api.heroku.com') | ||
.get('/apps/myapp/releases/10') | ||
.reply(200, release) | ||
.get('/apps/myapp/releases/10/config-vars') | ||
.reply(200, configVars) | ||
return runCommand(Cmd, [ | ||
await runCommand(Cmd, [ | ||
'--app', | ||
'myapp', | ||
'v10', | ||
]) | ||
.then(() => expect(stdout.output).to.equal(`=== Release v10\n\nAdd-ons: addon1\n addon2\nBy: [email protected]\nChange: something changed\nWhen: ${d.toISOString()}\n\n=== v10 Config vars\n\nBAR: bar\nFOO: foo\n`)) | ||
.then(() => api.done()) | ||
expectOutput(stdout.output, heredoc(` | ||
=== Release v10 | ||
Add-ons: addon1 | ||
addon2 | ||
By: [email protected] | ||
Change: something changed | ||
Eligible for Rollback?: Yes | ||
When: ${d.toISOString()} | ||
=== v10 Config vars | ||
BAR: bar | ||
FOO: foo | ||
`)) | ||
}) | ||
|
||
it('shows recent release as json', function () { | ||
const api = nock('https://api.heroku.com:443') | ||
it('shows recent release as json', async function () { | ||
nock('https://api.heroku.com') | ||
.get('/apps/myapp/releases/10') | ||
.reply(200, release) | ||
return runCommand(Cmd, [ | ||
await runCommand(Cmd, [ | ||
'--app', | ||
'myapp', | ||
'--json', | ||
'v10', | ||
]) | ||
.then(() => expect(stdout.output).to.contain('"version": 10')) | ||
.then(() => api.done()) | ||
expect(stdout.output).to.contain('"version": 10') | ||
}) | ||
|
||
it('shows a failed release info', async function () { | ||
nock('https://api.heroku.com') | ||
.get('/apps/myapp/releases') | ||
.reply(200, [{ | ||
description: 'something changed', | ||
status: 'failed', | ||
eligible_for_rollback: false, | ||
user: {email: '[email protected]'}, | ||
created_at: d, | ||
version: 10, | ||
}]) | ||
.get('/apps/myapp/releases/10/config-vars') | ||
.reply(200, configVars) | ||
await runCommand(Cmd, [ | ||
'--app', | ||
'myapp', | ||
]) | ||
expectOutput(stdout.output, heredoc(` | ||
=== Release v10 | ||
By: [email protected] | ||
Change: something changed (release command failed) | ||
Eligible for Rollback?: No | ||
When: ${d.toISOString()} | ||
=== v10 Config vars | ||
BAR: bar | ||
FOO: foo | ||
`)) | ||
}) | ||
|
||
it('shows a failed release info', function () { | ||
const api = nock('https://api.heroku.com:443') | ||
it('shows a pending release info', async function () { | ||
nock('https://api.heroku.com') | ||
.get('/apps/myapp/releases') | ||
.reply(200, [{ | ||
description: 'something changed', status: 'failed', user: {email: '[email protected]'}, created_at: d, version: 10, | ||
addon_plan_names: ['addon1', 'addon2'], | ||
description: 'something changed', | ||
status: 'pending', | ||
user: {email: '[email protected]'}, | ||
version: 10, | ||
eligible_for_rollback: false, | ||
created_at: d, | ||
}]) | ||
.get('/apps/myapp/releases/10/config-vars') | ||
.reply(200, configVars) | ||
return runCommand(Cmd, [ | ||
await runCommand(Cmd, [ | ||
'--app', | ||
'myapp', | ||
]) | ||
.then(() => expect(stdout.output).to.equal(`=== Release v10\n\nBy: [email protected]\nChange: something changed (release command failed)\nWhen: ${d.toISOString()}\n\n=== v10 Config vars\n\nBAR: bar\nFOO: foo\n`)) | ||
.then(() => api.done()) | ||
expectOutput(stdout.output, heredoc(` | ||
=== Release v10 | ||
Add-ons: addon1 | ||
addon2 | ||
By: [email protected] | ||
Change: something changed (release command executing) | ||
Eligible for Rollback?: No | ||
When: ${d.toISOString()} | ||
=== v10 Config vars | ||
BAR: bar | ||
FOO: foo | ||
`)) | ||
}) | ||
|
||
it('shows a pending release info', function () { | ||
const api = nock('https://api.heroku.com:443') | ||
it("shows an expired release's info", async function () { | ||
nock('https://api.heroku.com') | ||
.get('/apps/myapp/releases') | ||
.reply(200, [{ | ||
addon_plan_names: ['addon1', 'addon2'], description: 'something changed', status: 'pending', user: {email: '[email protected]'}, version: 10, created_at: d, | ||
description: 'something changed', | ||
status: 'expired', | ||
eligible_for_rollback: false, | ||
user: {email: '[email protected]'}, | ||
created_at: d, | ||
version: 10, | ||
}]) | ||
.get('/apps/myapp/releases/10/config-vars') | ||
.reply(200, configVars) | ||
return runCommand(Cmd, [ | ||
await runCommand(Cmd, [ | ||
'--app', | ||
'myapp', | ||
]) | ||
.then(() => expect(stdout.output).to.equal(`=== Release v10\n\nAdd-ons: addon1\n addon2\nBy: [email protected]\nChange: something changed (release command executing)\nWhen: ${d.toISOString()}\n\n=== v10 Config vars\n\nBAR: bar\nFOO: foo\n`)) | ||
.then(() => api.done()) | ||
expectOutput(stdout.output, heredoc(` | ||
=== Release v10 | ||
By: [email protected] | ||
Change: something changed (release expired) | ||
Eligible for Rollback?: No | ||
When: ${d.toISOString()} | ||
=== v10 Config vars | ||
BAR: bar | ||
FOO: foo | ||
`)) | ||
}) | ||
}) |
Oops, something went wrong.