Skip to content

Commit

Permalink
fix(apps-v5): get pipeline stage from pipeline_coupling
Browse files Browse the repository at this point in the history
[775c679][1] removed the `pipeline`
object from the `info` object used to render the display in `apps:info`
to fix a deprecation warning. Unfortunately, it seems like this
introduced a regression as code that was referencing `info.pipeline` was
not updated to use `info.pipeline_coupling`, resulting in runtime
exceptions due to trying to access a property off of `undefined`.

Work Item: [W-8780887][2]

[1]: 775c679
[2]: https://gus.lightning.force.com/lightning/r/ADM_Work__c/a07B00000094UCiIAM/view
  • Loading branch information
fivetanley committed Jan 22, 2021
1 parent e3c4b4b commit fbb68c1
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/apps-v5/src/commands/apps/info.js
Expand Up @@ -58,7 +58,7 @@ function * run (context, heroku) {
if (info.app.create_status !== 'complete') data['Create Status'] = info.app.create_status
if (info.app.space) data['Space'] = info.app.space.name
if (info.app.space && info.app.internal_routing) data['Internal Routing'] = info.app.internal_routing
if (info.pipeline_coupling) data['Pipeline'] = `${info.pipeline_coupling.pipeline.name} - ${info.pipeline.stage}`
if (info.pipeline_coupling) data['Pipeline'] = `${info.pipeline_coupling.pipeline.name} - ${info.pipeline_coupling.stage}`

data['Auto Cert Mgmt'] = info.app.acm
data['Git URL'] = info.app.git_url
Expand Down Expand Up @@ -100,7 +100,7 @@ function * run (context, heroku) {
if (info.app.cron_next_run) print('cron_next_run', cli.formatDate(new Date(info.app.cron_next_run)))
if (info.app.database_size) print('database_size', filesize(info.app.database_size, { round: 0 }))
if (info.app.create_status !== 'complete') print('create_status', info.app.create_status)
if (info.pipeline_coupling) print('pipeline', `${info.pipeline_coupling.pipeline.name}:${info.pipeline.stage}`)
if (info.pipeline_coupling) print('pipeline', `${info.pipeline_coupling.pipeline.name}:${info.pipeline_coupling.stage}`)

print('git_url', info.app.git_url)
print('web_url', info.app.web_url)
Expand Down
66 changes: 66 additions & 0 deletions packages/apps-v5/test/commands/apps/info.js
Expand Up @@ -193,6 +193,42 @@ Web URL: https://myapp.herokuapp.com
.then(() => expect(context.app).to.equal('myapp'))
})

it('shows app info via arg when the app is in a pipeline', () => {
let appApi = nock('https://api.heroku.com', {
reqheaders: { 'Accept': 'application/vnd.heroku+json; version=3.cedar-acm' }
}).get('/apps/myapp').reply(200, appAcm)

let api = nock('https://api.heroku.com:443')
.get('/apps/myapp/pipeline-couplings').reply(200, { app: { id: appAcm.id }, pipeline: { name: 'my-pipeline' }, stage: 'production' })
.get('/apps/myapp/addons').reply(200, addons)
.get('/apps/myapp/collaborators').reply(200, collaborators)
.get('/apps/myapp/dynos').reply(200, [{ type: 'web', size: 'Standard-1X', quantity: 2 }])
let context = { args: { app: 'myapp' }, flags: {} }
return cmd.run(context)
.then(() => expect(cli.stderr).to.equal(''))
.then(() => expect(cli.stdout).to.equal(`=== myapp
Addons: heroku-redis
papertrail
Auto Cert Mgmt: true
Collaborators: foo2@foo.com
Database Size: 1000 B
Dynos: web: 1
Git URL: https://git.heroku.com/myapp
Internal Routing: true
Owner: foo@foo.com
Pipeline: my-pipeline - production
Region: eu
Repo Size: 1000 B
Slug Size: 1000 B
Space: myspace
Stack: cedar-14
Web URL: https://myapp.herokuapp.com
`))
.then(() => appApi.done())
.then(() => api.done())
.then(() => expect(context.app).to.equal('myapp'))
})

it('shows app info in shell format', () => {
let appApi = nock('https://api.heroku.com', {
reqheaders: { 'Accept': 'application/vnd.heroku+json; version=3.cedar-acm' }
Expand Down Expand Up @@ -221,6 +257,36 @@ stack=cedar-14
.then(() => api.done())
})

it('shows app info in shell format when the app is in pipeline', () => {
let appApi = nock('https://api.heroku.com', {
reqheaders: { 'Accept': 'application/vnd.heroku+json; version=3.cedar-acm' }
}).get('/apps/myapp').reply(200, appAcm)

let api = nock('https://api.heroku.com:443')
.get('/apps/myapp/pipeline-couplings').reply(200, { app: { id: appAcm.id }, pipeline: { name: 'my-pipeline' }, stage: 'production' })
.get('/apps/myapp/addons').reply(200, addons)
.get('/apps/myapp/collaborators').reply(200, collaborators)
.get('/apps/myapp/dynos').reply(200, [{ type: 'web', size: 'Standard-1X', quantity: 2 }])
return cmd.run({ args: { app: 'myapp' }, flags: { shell: true } })
.then(() => expect(cli.stderr).to.equal(''))
.then(() => expect(cli.stdout).to.equal(`auto_cert_mgmt=true
addons=heroku-redis,papertrail
collaborators=foo2@foo.com
database_size=1000 B
pipeline=my-pipeline:production
git_url=https://git.heroku.com/myapp
web_url=https://myapp.herokuapp.com
repo_size=1000 B
slug_size=1000 B
owner=foo@foo.com
region=eu
dynos={ web: 1 }
stack=cedar-14
`))
.then(() => appApi.done())
.then(() => api.done())
})

it('shows extended app info in json format', () => {
let appApi = nock('https://api.heroku.com', {
reqheaders: { 'Accept': 'application/vnd.heroku+json; version=3.cedar-acm' }
Expand Down

0 comments on commit fbb68c1

Please sign in to comment.