UNPKG

1.69 kBJavaScriptView Raw
1/* eslint-env mocha */
2
3const nock = require('nock')
4const expect = require('chai').expect
5const cli = require('heroku-cli-util')
6const cmd = require('../../../commands/ci/config-index')
7
8describe('heroku ci:config', function () {
9 let app, coupling, key, value
10
11 beforeEach(function () {
12 cli.mockConsole()
13 app = '123-app'
14 key = 'FOO'
15 value = 'bar'
16
17 coupling = {
18 pipeline: {
19 id: '123-abc',
20 name: 'test-pipeline'
21 }
22 }
23 })
24
25 it('displays config', function* () {
26 const api = nock('https://api.heroku.com')
27 .get(`/apps/${app}/pipeline-couplings`)
28 .reply(200, coupling)
29 .get(`/pipelines/${coupling.pipeline.id}/stage/test/config-vars`)
30 .reply(200, { [key]: value })
31
32 yield cmd.run({ app, flags: {} })
33
34 expect(cli.stdout).to.include(`${key}: ${value}`)
35 api.done()
36 })
37
38 it('displays config formatted for shell', function* () {
39 const api = nock('https://api.heroku.com')
40 .get(`/apps/${app}/pipeline-couplings`)
41 .reply(200, coupling)
42 .get(`/pipelines/${coupling.pipeline.id}/stage/test/config-vars`)
43 .reply(200, { [key]: value })
44
45 yield cmd.run({ app, flags: { shell: true } })
46
47 expect(cli.stdout).to.include(`${key}=${value}`)
48 api.done()
49 })
50
51 it('displays config formatted as JSON', function* () {
52 const api = nock('https://api.heroku.com')
53 .get(`/apps/${app}/pipeline-couplings`)
54 .reply(200, coupling)
55 .get(`/pipelines/${coupling.pipeline.id}/stage/test/config-vars`)
56 .reply(200, { [key]: value })
57
58 yield cmd.run({ app, flags: { json: true } })
59
60 expect(cli.stdout).to.include('{\n "FOO": "bar"\n}')
61 api.done()
62 })
63})