Skip to content

Commit

Permalink
feat: add generation column to spaces command (#3029)
Browse files Browse the repository at this point in the history
* feat: add generation column to spaces command

* chore: udpate types reference

* test: update spaces/index tests to include generation in table
  • Loading branch information
k80bowman authored Oct 10, 2024
1 parent 07c1e88 commit 79c17fa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
11 changes: 8 additions & 3 deletions packages/cli/src/commands/spaces/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import color from '@heroku-cli/color'
import {Command, flags as Flags} from '@heroku-cli/command'
import {ux} from '@oclif/core'
import * as Heroku from '@heroku-cli/schema'
import {Space} from '../../lib/types/fir'

type SpaceArray = Array<Required<Heroku.Space>>
type SpaceArray = Array<Required<Space>>

export default class Index extends Command {
static topic = 'spaces'
Expand All @@ -16,7 +16,11 @@ export default class Index extends Command {
public async run(): Promise<void> {
const {flags} = await this.parse(Index)
const {team, json} = flags
let {body: spaces} = await this.heroku.get<SpaceArray>('/spaces')
let {body: spaces} = await this.heroku.get<SpaceArray>('/spaces', {
headers: {
Accept: 'application/vnd.heroku+json; version=3.fir',
},
})
if (team) {
spaces = spaces.filter(s => s.team.name === team)
}
Expand Down Expand Up @@ -54,6 +58,7 @@ export default class Index extends Command {
Team: {get: space => space.team.name},
Region: {get: space => space.region.name},
State: {get: space => space.state},
Generation: {get: space => space.generation},
createdAt: {
header: 'Created At',
get: space => space.created_at,
Expand Down
17 changes: 10 additions & 7 deletions packages/cli/test/unit/commands/spaces/index.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('spaces', function () {
region: {name: 'my-region'},
state: 'allocated',
created_at: now.toISOString(),
generation: 'cedar',
}]

afterEach(function () {
Expand All @@ -30,9 +31,9 @@ describe('spaces', function () {

api.done()
expect(heredoc(stdout.output)).to.eq(heredoc`
Name Team Region State Created At
──────── ─────── ───────── ───────── ────────────────────────
my-space my-team my-region allocated ${now.toISOString()}
Name Team Region State Generation Created At
──────── ─────── ───────── ───────── ────────── ────────────────────────
my-space my-team my-region allocated cedar ${now.toISOString()}
`)
})

Expand All @@ -55,15 +56,17 @@ describe('spaces', function () {
team: {name: 'other-team'},
region: {name: 'my-region'},
state: 'allocated',
created_at: now.toISOString()}]))
created_at: now.toISOString(),
generation: 'cedar',
}]))

await runCommand(Cmd, ['--team', 'my-team'])

api.done()
expect(heredoc(stdout.output)).to.eq(heredoc`
Name Team Region State Created At
──────── ─────── ───────── ───────── ────────────────────────
my-space my-team my-region allocated ${now.toISOString()}
Name Team Region State Generation Created At
──────── ─────── ───────── ───────── ────────── ────────────────────────
my-space my-team my-region allocated cedar ${now.toISOString()}
`)
})

Expand Down

0 comments on commit 79c17fa

Please sign in to comment.