UNPKG

1.31 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-get')
7
8describe('heroku ci:config:get', 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 the config value', 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, args: { key }, flags: {} })
33
34 expect(cli.stdout).to.equal(`${value}\n`)
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, args: { key }, flags: { shell: true } })
46
47 expect(cli.stdout).to.equal(`${key}=${value}\n`)
48 api.done()
49 })
50})