From 7044e303cc68c4e44bf48a2683ae722daed7a761 Mon Sep 17 00:00:00 2001 From: Jon Daniel Date: Mon, 12 Feb 2024 12:15:20 -0500 Subject: [PATCH] Updates default host to api.data.heroku.com (#219) * 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 --- .github/workflows/tests.yaml | 4 ++-- lib/host.js | 12 +----------- test/commands/consumer_groups_create_test.js | 2 +- test/commands/consumer_groups_destroy_test.js | 2 +- test/commands/consumer_groups_test.js | 2 +- test/commands/credentials_rotate_test.js | 2 +- test/commands/fail_test.js | 2 +- test/commands/host_test.js | 2 +- test/commands/info_test.js | 2 +- test/commands/topics_compaction_test.js | 2 +- test/commands/topics_create_test.js | 2 +- test/commands/topics_destroy_test.js | 2 +- test/commands/topics_info_test.js | 2 +- test/commands/topics_replication_factor_test.js | 2 +- test/commands/topics_retention_time_test.js | 2 +- test/commands/topics_test.js | 2 +- test/commands/upgrade_test.js | 2 +- test/commands/wait_test.js | 2 +- test/commands/zookeeper_test.js | 2 +- test/lib/clusters_test.js | 8 ++++---- test/lib/utilizationBar_test.js | 11 +++++++++-- 21 files changed, 33 insertions(+), 36 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 5b186ab..7581c54 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -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 diff --git a/lib/host.js b/lib/host.js index ae1bfa9..c36a06c 100644 --- a/lib/host.js +++ b/lib/host.js @@ -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' } diff --git a/test/commands/consumer_groups_create_test.js b/test/commands/consumer_groups_create_test.js index b16588d..3fcdb71 100644 --- a/test/commands/consumer_groups_create_test.js +++ b/test/commands/consumer_groups_create_test.js @@ -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() }) diff --git a/test/commands/consumer_groups_destroy_test.js b/test/commands/consumer_groups_destroy_test.js index 34a95c2..ede710d 100644 --- a/test/commands/consumer_groups_destroy_test.js +++ b/test/commands/consumer_groups_destroy_test.js @@ -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 diff --git a/test/commands/consumer_groups_test.js b/test/commands/consumer_groups_test.js index 23200d6..bc7888e 100644 --- a/test/commands/consumer_groups_test.js +++ b/test/commands/consumer_groups_test.js @@ -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() }) diff --git a/test/commands/credentials_rotate_test.js b/test/commands/credentials_rotate_test.js index 3517066..0842934 100644 --- a/test/commands/credentials_rotate_test.js +++ b/test/commands/credentials_rotate_test.js @@ -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() }) diff --git a/test/commands/fail_test.js b/test/commands/fail_test.js index 612877c..c29dd9f 100644 --- a/test/commands/fail_test.js +++ b/test/commands/fail_test.js @@ -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() diff --git a/test/commands/host_test.js b/test/commands/host_test.js index c152a92..21191be 100644 --- a/test/commands/host_test.js +++ b/test/commands/host_test.js @@ -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') }) }) diff --git a/test/commands/info_test.js b/test/commands/info_test.js index b4a14fa..09cf47b 100644 --- a/test/commands/info_test.js +++ b/test/commands/info_test.js @@ -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() }) diff --git a/test/commands/topics_compaction_test.js b/test/commands/topics_compaction_test.js index 089bcb2..2cc380f 100644 --- a/test/commands/topics_compaction_test.js +++ b/test/commands/topics_compaction_test.js @@ -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() }) diff --git a/test/commands/topics_create_test.js b/test/commands/topics_create_test.js index e959330..cc69848 100644 --- a/test/commands/topics_create_test.js +++ b/test/commands/topics_create_test.js @@ -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() diff --git a/test/commands/topics_destroy_test.js b/test/commands/topics_destroy_test.js index 706305a..8b1ca93 100644 --- a/test/commands/topics_destroy_test.js +++ b/test/commands/topics_destroy_test.js @@ -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 diff --git a/test/commands/topics_info_test.js b/test/commands/topics_info_test.js index eb9e0d9..64dad52 100644 --- a/test/commands/topics_info_test.js +++ b/test/commands/topics_info_test.js @@ -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() }) diff --git a/test/commands/topics_replication_factor_test.js b/test/commands/topics_replication_factor_test.js index 5680e8b..e26cb68 100644 --- a/test/commands/topics_replication_factor_test.js +++ b/test/commands/topics_replication_factor_test.js @@ -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() }) diff --git a/test/commands/topics_retention_time_test.js b/test/commands/topics_retention_time_test.js index e0d80f5..197f34e 100644 --- a/test/commands/topics_retention_time_test.js +++ b/test/commands/topics_retention_time_test.js @@ -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() }) diff --git a/test/commands/topics_test.js b/test/commands/topics_test.js index b94ef49..e3d4c02 100644 --- a/test/commands/topics_test.js +++ b/test/commands/topics_test.js @@ -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() }) diff --git a/test/commands/upgrade_test.js b/test/commands/upgrade_test.js index e13c8c5..4c5827b 100644 --- a/test/commands/upgrade_test.js +++ b/test/commands/upgrade_test.js @@ -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() diff --git a/test/commands/wait_test.js b/test/commands/wait_test.js index 503eb74..e257d2c 100644 --- a/test/commands/wait_test.js +++ b/test/commands/wait_test.js @@ -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(() => { diff --git a/test/commands/zookeeper_test.js b/test/commands/zookeeper_test.js index c963132..aab06a9 100644 --- a/test/commands/zookeeper_test.js +++ b/test/commands/zookeeper_test.js @@ -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() }) diff --git a/test/lib/clusters_test.js b/test/lib/clusters_test.js index 4194446..e713b6e 100644 --- a/test/lib/clusters_test.js +++ b/test/lib/clusters_test.js @@ -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({ @@ -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({ @@ -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({ @@ -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({ diff --git a/test/lib/utilizationBar_test.js b/test/lib/utilizationBar_test.js index 4d7d3c5..53ce188 100644 --- a/test/lib/utilizationBar_test.js +++ b/test/lib/utilizationBar_test.js @@ -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) }) }) })