-
Notifications
You must be signed in to change notification settings - Fork 17
/
consumer_groups_create_test.js
59 lines (48 loc) · 1.41 KB
/
consumer_groups_create_test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
'use strict'
const expect = require('chai').expect
const mocha = require('mocha')
const describe = mocha.describe
const it = mocha.it
const beforeEach = mocha.beforeEach
const afterEach = mocha.afterEach
const proxyquire = require('proxyquire')
const cli = require('heroku-cli-util')
const nock = require('nock')
const withCluster = function * (heroku, app, cluster, callback) {
yield callback({ name: 'kafka-1', id: '00000000-0000-0000-0000-000000000000' })
}
const VERSION = 'v0'
const cmd = proxyquire('../../commands/consumer_groups_create', {
'../lib/clusters': {
withCluster
}
})
describe('kafka:consumer-groups:create', () => {
let kafka
let consumerGroupsUrl = (cluster) => {
return `/data/kafka/${VERSION}/clusters/${cluster}/consumer_groups`
}
beforeEach(() => {
kafka = nock('https://kafka-api.heroku.com:443')
cli.mockConsole()
cli.exit.mock()
})
afterEach(() => {
nock.cleanAll()
kafka.done()
})
it('creates a consumer group on the cluster', () => {
kafka.post(consumerGroupsUrl('00000000-0000-0000-0000-000000000000'),
{
consumer_group: {
name: 'consumer-group-1'
}
}
).reply(200)
return cmd.run({app: 'myapp',
args: { CONSUMER_GROUP: 'consumer-group-1' }})
.then(() => {
expect(cli.stdout).to.equal('Use `heroku kafka:consumer-groups` to list your consumer groups.\n')
})
})
})