Skip to content

Commit

Permalink
fix: only print slug size for apps:info for non-fir apps (#3129)
Browse files Browse the repository at this point in the history
* fix: only print slug size for apps:info for non-fir apps

* test: update apps:info tests for slug size and add fir tests
  • Loading branch information
k80bowman authored Dec 6, 2024
1 parent 48c5b8e commit 91b48f2
Show file tree
Hide file tree
Showing 2 changed files with 97 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/cli/src/commands/apps/info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function print(info: Heroku.App, addons: Heroku.AddOn[], collaborators: Heroku.C
data['Git URL'] = info.app.git_url
data['Web URL'] = info.app.web_url
data['Repo Size'] = filesize(info.app.repo_size, {standard: 'jedec', round: 0})
data['Slug Size'] = filesize(info.app.slug_size, {standard: 'jedec', round: 0})
if (info.app.generation.name !== 'fir') data['Slug Size'] = filesize(info.app.slug_size, {standard: 'jedec', round: 0})
data.Owner = info.app.owner.email
data.Region = info.app.region.name
data.Dynos = countBy(info.dynos, 'type')
Expand Down Expand Up @@ -159,7 +159,7 @@ repo_size=5000000
print('git_url', info.app.git_url)
print('web_url', info.app.web_url)
print('repo_size', filesize(info.app.repo_size, {standard: 'jedec', round: 0}))
print('slug_size', filesize(info.app.slug_size, {standard: 'jedec', round: 0}))
if (info.app.generation.name !== 'fir') print('slug_size', filesize(info.app.slug_size, {standard: 'jedec', round: 0}))
print('owner', info.app.owner.email)
print('region', info.app.region.name)
print('dynos', util.inspect(countBy(info.dynos, 'type')))
Expand Down
95 changes: 95 additions & 0 deletions packages/cli/test/unit/commands/apps/info.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,25 @@ const app = {
stack: {name: 'cedar-14'},
owner: {email: '[email protected]'},
space: {name: 'myspace'},
generation: {id: '123', name: 'cedar'},
internal_routing: true,
}

const firApp = {
id: 'app-id',
name: 'myapp',
database_size: 1000,
create_status: 'complete',
repo_size: 1000,
slug_size: null,
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: '[email protected]'},
space: {name: 'myspace'},
generation: {id: '123', name: 'fir'},
internal_routing: true,
}

Expand All @@ -33,6 +52,10 @@ const appAcm = Object.assign({}, app, {
acm: true,
})

const firAppAcm = Object.assign({}, firApp, {
acm: true,
})

const addons = [
{plan: {name: 'papertrail'}},
{plan: {name: 'heroku-redis'}},
Expand Down Expand Up @@ -62,6 +85,24 @@ Stack: cedar-14
Web URL: https://myapp.herokuapp.com
`

const BASE_INFO_FIR = `=== myapp
Addons: heroku-redis
papertrail
Auto Cert Mgmt: true
Collaborators: [email protected]
Database Size: 1000 B
Dynos: web: 1
Git URL: https://git.heroku.com/myapp
Internal Routing: true
Owner: [email protected]
Region: eu
Repo Size: 1000 B
Space: myspace
Stack: cedar-14
Web URL: https://myapp.herokuapp.com
`

describe('apps:info', function () {
test
.stdout()
Expand Down Expand Up @@ -351,6 +392,60 @@ Slug Size: 1000 B
Space: myspace
Stack: cedar-14 (next build will use heroku-24)
Web URL: https://myapp.herokuapp.com
`)
expect(unwrap(stderr)).to.contains('')
})

test
.stdout()
.stderr()
.nock('https://api.heroku.com', api =>
api
.get('/apps/myapp')
.reply(200, firAppAcm),
)
.nock('https://api.heroku.com:443', api =>
api
.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}]),
)
.command(['apps:info', '-a', 'myapp'])
.it('shows fir app info without slug size', ({stdout, stderr}) => {
expect(stdout).to.equal(BASE_INFO_FIR)
expect(unwrap(stderr)).to.contains('')
})

test
.stdout()
.stderr()
.nock('https://api.heroku.com', api =>
api
.get('/apps/myapp')
.reply(200, firAppAcm),
)
.nock('https://api.heroku.com:443', api =>
api
.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}]),
)
.command(['apps:info', 'myapp', '--shell'])
.it('shows fir app info in shell format without slug size', ({stdout, stderr}) => {
expect(stdout).to.equal(`auto_cert_mgmt=true
addons=heroku-redis,papertrail
[email protected]
database_size=1000 B
git_url=https://git.heroku.com/myapp
web_url=https://myapp.herokuapp.com
repo_size=1000 B
[email protected]
region=eu
dynos={ web: 1 }
stack=cedar-14
`)
expect(unwrap(stderr)).to.contains('')
})
Expand Down

0 comments on commit 91b48f2

Please sign in to comment.