Skip to content

Commit

Permalink
Updates default host to api.data.heroku.com (#219)
Browse files Browse the repository at this point in the history
* Updates default host to api.data.heroku.com

* Trigger workflow

* Fix broken test

* Update test runner

* Update node-version from PR feedback

* Update environment variable name

---------

Co-authored-by: Zane Whitfield <[email protected]>
  • Loading branch information
binarycleric and zwhitfield3 authored Feb 12, 2024
1 parent 6591b52 commit 7044e30
Show file tree
Hide file tree
Showing 21 changed files with 33 additions and 36 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ on:
jobs:
tests:
name: Tests
runs-on: ubuntu-latest
runs-on: pub-hk-ubuntu-22.04-small

strategy:
matrix:
node-version: ["12.22.1", "14.16.1"]
node-version: ["16.20.2"]

steps:
- uses: actions/checkout@v3
Expand Down
12 changes: 1 addition & 11 deletions lib/host.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
'use strict'

let DEFAULT_HOST = 'kafka-api.heroku.com'

module.exports = function () {
if (process.env.HEROKU_KAFKA_HOST) {
return process.env.HEROKU_KAFKA_HOST
} else if (process.env.SHOGUN) {
return `shogun-${process.env.SHOGUN}.herokuapp.com`
} else if (process.env.DEPLOY) {
return `shogun-${process.env.DEPLOY}.herokuapp.com`
} else {
return DEFAULT_HOST
}
return process.env.HEROKU_DATA_HOST || 'api.data.heroku.com'
}
2 changes: 1 addition & 1 deletion test/commands/consumer_groups_create_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('kafka:consumer-groups:create', () => {
}

beforeEach(() => {
kafka = nock('https://kafka-api.heroku.com:443')
kafka = nock('https://api.data.heroku.com:443')
cli.mockConsole()
cli.exit.mock()
})
Expand Down
2 changes: 1 addition & 1 deletion test/commands/consumer_groups_destroy_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('kafka:consumer-groups:destroy', () => {

beforeEach(() => {
confirm = cli.confirmApp
kafka = nock('https://kafka-api.heroku.com:443')
kafka = nock('https://api.data.heroku.com:443')

cli.exit.mock()
cli.confirmApp = confirmApp
Expand Down
2 changes: 1 addition & 1 deletion test/commands/consumer_groups_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('kafka:consumer-groups', () => {
}

beforeEach(() => {
kafka = nock('https://kafka-api.heroku.com:443')
kafka = nock('https://api.data.heroku.com:443')
cli.mockConsole()
cli.exit.mock()
})
Expand Down
2 changes: 1 addition & 1 deletion test/commands/credentials_rotate_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('kafka:credentials', () => {

beforeEach(() => {
planName = 'heroku-kafka:beta-private-standard-2'
kafka = nock('https://kafka-api.heroku.com:443')
kafka = nock('https://api.data.heroku.com:443')
cli.mockConsole()
cli.exit.mock()
})
Expand Down
2 changes: 1 addition & 1 deletion test/commands/fail_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('kafka:fail', () => {

beforeEach(() => {
confirm = cli.confirmApp
kafka = nock('https://kafka-api.heroku.com:443')
kafka = nock('https://api.data.heroku.com:443')

cli.confirmApp = confirmApp
cli.mockConsole()
Expand Down
2 changes: 1 addition & 1 deletion test/commands/host_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ const host = require('../../lib/host.js')

describe('host', () => {
it(`is the default host`, () => {
expect(host()).to.equal('kafka-api.heroku.com')
expect(host()).to.equal('api.data.heroku.com')
})
})
2 changes: 1 addition & 1 deletion test/commands/info_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ describe('kafka:info', () => {

beforeEach(() => {
api = nock('https://api.heroku.com:443')
kafka = nock('https://kafka-api.heroku.com:443')
kafka = nock('https://api.data.heroku.com:443')
cli.mockConsole()
})

Expand Down
2 changes: 1 addition & 1 deletion test/commands/topics_compaction_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('kafka:topics:compaction', () => {
}

beforeEach(() => {
kafka = nock('https://kafka-api.heroku.com:443')
kafka = nock('https://api.data.heroku.com:443')
cli.mockConsole()
cli.exit.mock()
})
Expand Down
2 changes: 1 addition & 1 deletion test/commands/topics_create_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ describe('kafka:topics:create', () => {
}

beforeEach(() => {
kafka = nock('https://kafka-api.heroku.com:443')
kafka = nock('https://api.data.heroku.com:443')

cli.exit.mock()
cli.mockConsole()
Expand Down
2 changes: 1 addition & 1 deletion test/commands/topics_destroy_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('kafka:topics:destroy', () => {

beforeEach(() => {
confirm = cli.confirmApp
kafka = nock('https://kafka-api.heroku.com:443')
kafka = nock('https://api.data.heroku.com:443')

cli.exit.mock()
cli.confirmApp = confirmApp
Expand Down
2 changes: 1 addition & 1 deletion test/commands/topics_info_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe('kafka:topics:info', () => {
}

beforeEach(() => {
kafka = nock('https://kafka-api.heroku.com:443')
kafka = nock('https://api.data.heroku.com:443')
cli.mockConsole()
cli.exit.mock()
})
Expand Down
2 changes: 1 addition & 1 deletion test/commands/topics_replication_factor_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ describe('kafka:topics:replication-factor', () => {
}

beforeEach(() => {
kafka = nock('https://kafka-api.heroku.com:443')
kafka = nock('https://api.data.heroku.com:443')
cli.mockConsole()
cli.exit.mock()
})
Expand Down
2 changes: 1 addition & 1 deletion test/commands/topics_retention_time_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('kafka:topics:retention-time', () => {
}

beforeEach(() => {
kafka = nock('https://kafka-api.heroku.com:443')
kafka = nock('https://api.data.heroku.com:443')
cli.mockConsole()
cli.exit.mock()
})
Expand Down
2 changes: 1 addition & 1 deletion test/commands/topics_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('kafka:topics', () => {
}

beforeEach(() => {
kafka = nock('https://kafka-api.heroku.com:443')
kafka = nock('https://api.data.heroku.com:443')
cli.mockConsole()
cli.exit.mock()
})
Expand Down
2 changes: 1 addition & 1 deletion test/commands/upgrade_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('kafka:upgrade', () => {

beforeEach(() => {
confirm = cli.confirmApp
kafka = nock('https://kafka-api.heroku.com:443')
kafka = nock('https://api.data.heroku.com:443')

cli.confirmApp = confirmApp
cli.mockConsole()
Expand Down
2 changes: 1 addition & 1 deletion test/commands/wait_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('kafka:wait', () => {
beforeEach(() => {
cli.mockConsole()
cli.exit.mock()
kafka = nock('https://kafka-api.heroku.com')
kafka = nock('https://api.data.heroku.com')
})

afterEach(() => {
Expand Down
2 changes: 1 addition & 1 deletion test/commands/zookeeper_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ describe('kafka:zookeeper', () => {

beforeEach(() => {
planName = 'heroku-kafka:private-standard-2'
kafka = nock('https://kafka-api.heroku.com:443')
kafka = nock('https://api.data.heroku.com:443')
cli.mockConsole()
cli.exit.mock()
})
Expand Down
8 changes: 4 additions & 4 deletions test/lib/clusters_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ describe('topicConfig', () => {
const topicName = 'foo'
const heroku = {
request: td.when(td.function()({
host: 'kafka-api.heroku.com',
host: 'api.data.heroku.com',
accept: 'application/json',
path: `/data/kafka/v0/clusters/${addonId}/topics`
})).thenResolve({
Expand All @@ -141,7 +141,7 @@ describe('topicConfig', () => {
const topicPrefix = 'wisła-3456.'
const heroku = {
request: td.when(td.function()({
host: 'kafka-api.heroku.com',
host: 'api.data.heroku.com',
accept: 'application/json',
path: `/data/kafka/v0/clusters/${addonId}/topics`
})).thenResolve({
Expand All @@ -161,7 +161,7 @@ describe('topicConfig', () => {
const topicPrefix = 'wisła-3456.'
const heroku = {
request: td.when(td.function()({
host: 'kafka-api.heroku.com',
host: 'api.data.heroku.com',
accept: 'application/json',
path: `/data/kafka/v0/clusters/${addonId}/topics`
})).thenResolve({
Expand All @@ -180,7 +180,7 @@ describe('topicConfig', () => {
const topicName = 'foo'
const heroku = {
request: td.when(td.function()({
host: 'kafka-api.heroku.com',
host: 'api.data.heroku.com',
accept: 'application/json',
path: `/data/kafka/v0/clusters/${addonId}/topics`
})).thenResolve({
Expand Down
11 changes: 9 additions & 2 deletions test/lib/utilizationBar_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,15 @@ describe('utilizationBar', function () {
const expected10 = testcase[2]
const expected15 = testcase[3]
it(`Renders a ${current}/${total} bar correctly`, function () {
expect(utilizationBar(current, total)).to.equal(expected10)
expect(utilizationBar(current, total, 15)).to.equal(expected15)
const resultWithANSI = utilizationBar(current, total)
// eslint-disable-next-line no-control-regex
const resultWithoutANSI = resultWithANSI.replace(/\x1B\[[0-?]*[ -/]*[@-~]/g, '')
const result2WithANSI = utilizationBar(current, total, 15)
// eslint-disable-next-line no-control-regex
const result2WithoutANSI = result2WithANSI.replace(/\x1B\[[0-?]*[ -/]*[@-~]/g, '')

expect(resultWithoutANSI).to.equal(expected10)
expect(result2WithoutANSI).to.equal(expected15)
})
})
})

0 comments on commit 7044e30

Please sign in to comment.