{"size": 1404, "ext": "js", "max_stars_repo_path": "packages/spaces/test/commands/peering/info.js", "max_stars_repo_name": "fahrradflucht/cli", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "packages/spaces/test/commands/peering/info.js", "max_issues_repo_name": "fahrradflucht/cli", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "packages/spaces/test/commands/peering/info.js", "max_forks_repo_name": "fahrradflucht/cli", "max_forks_repo_forks_event_min_datetime": "2020-11-04T06:15:03.000Z", "max_forks_repo_forks_event_max_datetime": "2020-11-04T06:15:03.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 29.25, "max_line_length": 62, "alphanum_fraction": 0.6004273504}
'use strict'
/* globals describe beforeEach it */

let nock = require('nock')
let cmd = require('../../../commands/peering/info')
let expect = require('chai').expect
let cli = require('heroku-cli-util')
let info = {
  aws_account_id: '012345678900',
  aws_region: 'us-west-2',
  vpc_id: 'vpc-1234568a',
  vpc_cidr: '10.0.0.0/16',
  space_cidr_blocks: ['10.0.128.0/20', '10.0.144.0/20'],
  unavailable_cidr_blocks: ['192.168.2.0/30']}

describe('spaces:peering-info', function () {
  beforeEach(() => cli.mockConsole())

  it('shows space peering info', function () {
    let api = nock('https://api.heroku.com:443')
      .get('/spaces/my-space/peering-info')
      .reply(200,
        info
      )
    return cmd.run({flags: {space: 'my-space'}})
      .then(() => expect(cli.stdout).to.equal(
        `=== my-space Peering Info
AWS Account ID:    012345678900
AWS Region:        us-west-2
AWS VPC ID:        vpc-1234568a
AWS VPC CIDR:      10.0.0.0/16
Space CIDRs:       10.0.128.0/20, 10.0.144.0/20
Unavailable CIDRs: 192.168.2.0/30
`))
      .then(() => api.done())
  })

  it('shows peering:info --json', function () {
    let api = nock('https://api.heroku.com:443')
      .get('/spaces/my-space/peering-info')
      .reply(200, info)

    return cmd.run({flags: {space: 'my-space', json: true}})
      .then(() => expect(JSON.parse(cli.stdout)).to.eql(info))
      .then(() => api.done())
  })
})
