-
Notifications
You must be signed in to change notification settings - Fork 17
/
topics_info_test.js
71 lines (60 loc) · 1.81 KB
/
topics_info_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
60
61
62
63
64
65
66
67
68
69
70
71
'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.beforeEach
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 cmd = proxyquire('../../commands/topics_info', {
'../lib/clusters': {
withCluster
}
}).cmd
describe('kafka:topics:info', () => {
let kafka
let topicsUrl = (cluster) => {
return `/data/kafka/v0/clusters/${cluster}/topics`
}
beforeEach(() => {
kafka = nock('https://kafka-api.heroku.com:443')
cli.mockConsole()
cli.exit.mock()
})
afterEach(() => {
nock.cleanAll()
kafka.done()
})
it('displays the topic info', () => {
kafka.get(topicsUrl('00000000-0000-0000-0000-000000000000')).reply(200, {
attachment_name: 'HEROKU_KAFKA_BLUE_URL',
topics: [
{
name: 'topic-1',
messages_in_per_second: 0,
bytes_in_per_second: 0,
bytes_out_per_second: 0,
replication_factor: 3,
partitions: 3,
compaction_enabled: false,
retention_time_ms: 86400000
}
]
})
return cmd.run({app: 'myapp', args: { TOPIC: 'topic-1' }})
.then(() => expect(cli.stdout).to.equal(`=== HEROKU_KAFKA_BLUE_URL :: topic-1
Producers: 0 messages/second (0 bytes/second) total
Consumers: 0 bytes/second total
Partitions: 3 partitions
Replication Factor: 3 (recommend > 1)
Compaction: Compaction is disabled for topic-1
Retention: 24 hours
`))
.then(() => expect(cli.stderr).to.be.empty)
})
})