Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
fix: show stack change in app info (#232)
Browse files Browse the repository at this point in the history
  • Loading branch information
Damien Mathieu authored and jdx committed May 31, 2018
1 parent d87e41c commit 34642d2
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/commands/apps/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,13 @@ function * run (context, heroku) {
data['Owner'] = info.app.owner.email
data['Region'] = info.app.region.name
data['Dynos'] = countBy(info.dynos, 'type')
data['Stack'] = info.app.stack.name
data['Stack'] = (function (app) {
let stack = info.app.stack.name
if (app.stack.name !== app.build_stack.name) {
stack += ` (next build will use ${app.build_stack.name})`
}
return stack
})(info.app)

cli.styledHeader(info.app.name)
cli.styledObject(data)
Expand Down
35 changes: 35 additions & 0 deletions test/commands/apps/info.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ let app = {
git_url: 'https://git.heroku.com/myapp',
web_url: 'https://myapp.herokuapp.com',
region: {name: 'eu'},
build_stack: {name: 'cedar-14'},
stack: {name: 'cedar-14'},
owner: {email: 'foo@foo.com'},
space: {name: 'myspace'}
}

let appStackChange = Object.assign({}, app, {
build_stack: {name: 'heroku-18'}
})

let appExtended = Object.assign({}, app, {
extended: {
foo: 'bar',
Expand Down Expand Up @@ -257,4 +262,34 @@ stack=cedar-14
.then(() => appApi.done())
.then(() => api.done())
})

it('shows app info with a stack change', () => {
let appApi = nock('https://api.heroku.com', {
reqheaders: {'Accept': 'application/vnd.heroku+json; version=3.cedar-acm'}
}).get('/apps/myapp').reply(200, appStackChange)

let api = nock('https://api.heroku.com:443')
.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({app: 'myapp', args: {}, flags: {}})
.then(() => expect(cli.stderr).to.equal(''))
.then(() => expect(cli.stdout).to.equal(`=== myapp
Addons: heroku-redis
papertrail
Collaborators: foo2@foo.com
Database Size: 1000 B
Dynos: web: 1
Git URL: https://git.heroku.com/myapp
Owner: foo@foo.com
Region: eu
Repo Size: 1000 B
Slug Size: 1000 B
Space: myspace
Stack: cedar-14 (next build will use heroku-18)
Web URL: https://myapp.herokuapp.com
`))
.then(() => appApi.done())
.then(() => api.done())
})
})

0 comments on commit 34642d2

Please sign in to comment.