1 | 'use strict'
|
2 |
|
3 |
|
4 | const cli = require('heroku-cli-util')
|
5 | const expect = require('unexpected')
|
6 | const nock = require('nock')
|
7 | const proxyquire = require('proxyquire')
|
8 |
|
9 | const addon = {
|
10 | id: 1,
|
11 | name: 'postgres-1',
|
12 | plan: {name: 'heroku-postgresql:standard-0'}
|
13 | }
|
14 | const fetcher = () => {
|
15 | return {
|
16 | all: () => [addon],
|
17 | addon: () => addon
|
18 | }
|
19 | }
|
20 |
|
21 | const cmd = proxyquire('../../../commands/links', {
|
22 | '../../lib/fetcher': fetcher
|
23 | })
|
24 |
|
25 | describe('pg:links', () => {
|
26 | let api, pg
|
27 |
|
28 | beforeEach(() => {
|
29 | api = nock('https://api.heroku.com')
|
30 | pg = nock('https://postgres-api.heroku.com')
|
31 | cli.mockConsole()
|
32 | })
|
33 |
|
34 | afterEach(() => {
|
35 | nock.cleanAll()
|
36 | api.done()
|
37 | pg.done()
|
38 | })
|
39 |
|
40 | it('shows links', () => {
|
41 | pg.get('/client/v11/databases/1/links').reply(200, [
|
42 | {name: 'redis-link-1', created_at: '100', remote: {attachment_name: 'REDIS', name: 'redis-001'}}
|
43 | ])
|
44 | return cmd.run({app: 'myapp', args: {}, flags: {confirm: 'myapp'}})
|
45 | .then(() => expect(cli.stdout, 'to equal', `=== postgres-1
|
46 |
|
47 | * redis-link-1
|
48 | created_at: 100
|
49 | remote: REDIS (redis-001)
|
50 | `))
|
51 | })
|
52 | })
|