Skip to content

Commit

Permalink
Add variant to hosts command
Browse files Browse the repository at this point in the history
  • Loading branch information
eablack committed May 2, 2024
1 parent 2082582 commit 9232b99
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 13 deletions.
6 changes: 3 additions & 3 deletions packages/cli/src/commands/spaces/hosts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ export default class Hosts extends Command {
}

const {body: hosts} = await this.heroku.get<Host[]>(
`/spaces/${spaceName}/hosts`,
headers: {Accept: 'application/vnd.heroku+json; version=3.dogwood'}
)
`/spaces/${spaceName}/hosts`, {
headers: {Accept: 'application/vnd.heroku+json; version=3.dogwood'},
})
if (flags.json)
displayHostsAsJSON(hosts)
else
Expand Down
12 changes: 10 additions & 2 deletions packages/cli/test/unit/commands/spaces/hosts.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ describe('spaces:hosts', function () {
]

it('lists space hosts', async function () {
nock('https://api.heroku.com')
nock('https://api.heroku.com', {
reqheaders: {
Accept: 'application/vnd.heroku+json; version=3.dogwood',
},
})
.get('/spaces/my-space/hosts')
.reply(200, hosts)
await runCommand(Cmd, [
Expand All @@ -42,7 +46,11 @@ describe('spaces:hosts', function () {
})

it('shows hosts:info --json', async function () {
nock('https://api.heroku.com')
nock('https://api.heroku.com', {
reqheaders: {
Accept: 'application/vnd.heroku+json; version=3.dogwood',
},
})
.get('/spaces/my-space/hosts')
.reply(200, hosts)

Expand Down
17 changes: 13 additions & 4 deletions packages/cli/test/unit/commands/spaces/topology.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,21 @@ import heredoc from 'tsheredoc'
import expectOutput from '../../../helpers/utils/expectOutput'
import * as fixtures from '../../../fixtures/spaces/fixtures'
import {expect} from 'chai'
import type {SpaceTopology} from '../../../../src/commands/spaces/topology'
import {App} from '@heroku-cli/schema'

describe('spaces:topology', function () {
const topo1 = fixtures.topologies['topology-one']
const topo2 = fixtures.topologies['topology-two']
const topo3 = fixtures.topologies['topology-three']
const app = fixtures.apps.www
let topo1: SpaceTopology
let topo2: SpaceTopology
let topo3: SpaceTopology
let app: App

beforeEach(function () {
topo1 = fixtures.topologies['topology-one']
topo2 = fixtures.topologies['topology-two']
topo3 = fixtures.topologies['topology-three']
app = fixtures.apps.www
})

it('shows space topology', async function () {
nock('https://api.heroku.com')
Expand Down
11 changes: 7 additions & 4 deletions packages/cli/test/unit/commands/spaces/wait.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@ import {expect} from 'chai'
import expectOutput from '../../../helpers/utils/expectOutput'
import * as fixtures from '../../../fixtures/spaces/fixtures'
import * as sinon from 'sinon'
import {Space} from '@heroku-cli/schema'

describe('spaces:wait', function () {
const allocatingSpace = fixtures.spaces['allocating-space']
const allocatedSpace = fixtures.spaces['non-shield-space']
let allocatingSpace: Required<Space>
let allocatedSpace: Required<Space>
let sandbox: sinon.SinonSandbox
let notifySpy: sinon.SinonSpy

beforeEach(() => {
beforeEach(function () {
sandbox = sinon.createSandbox()
notifySpy = sandbox.spy(require('@heroku-cli/notifications'), 'notify')
allocatingSpace = fixtures.spaces['allocating-space']
allocatedSpace = fixtures.spaces['non-shield-space']
})

afterEach(() => {
afterEach(function () {
sandbox.restore()
})

Expand Down

0 comments on commit 9232b99

Please sign in to comment.