Skip to content

Commit

Permalink
remove shield from isPrivate() (#204)
Browse files Browse the repository at this point in the history
* remove shield from isPrivate()

* rename

* importexport

* tst

* missed

* missed
  • Loading branch information
jdowning committed Sep 15, 2020
1 parent 733b77f commit 7aab16b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions commands/zookeeper.js
Expand Up @@ -3,7 +3,7 @@
let cli = require('heroku-cli-util')
let co = require('co')
let parseBool = require('../lib/shared').parseBool
let isPrivate = require('../lib/shared').isPrivate
let isZookeeperAllowed = require('../lib/shared').isZookeeperAllowed
let withCluster = require('../lib/clusters').withCluster
let request = require('../lib/clusters').request

Expand All @@ -21,7 +21,7 @@ function * zookeeper (context, heroku) {
}

yield withCluster(heroku, context.app, context.args.CLUSTER, function * (addon) {
if (!isPrivate(addon)) {
if (!isZookeeperAllowed(addon)) {
cli.exit(1, '`kafka:zookeeper` is only available in Heroku Private Spaces')
}

Expand Down
6 changes: 3 additions & 3 deletions lib/shared.js
Expand Up @@ -40,8 +40,8 @@ function clusterConfig (attachment, config) {
}
}

function isPrivate (addon) {
return addon.plan.name.indexOf('private-') !== -1 || addon.plan.name.indexOf('shield-') !== -1
function isZookeeperAllowed (addon) {
return addon.plan.name.indexOf('private-') !== -1
}

function parseBool (boolStr) {
Expand Down Expand Up @@ -146,6 +146,6 @@ module.exports = {
deprecated,
parseBool,
parseDuration,
isPrivate,
isZookeeperAllowed,
formatIntervalFromMilliseconds
}
4 changes: 2 additions & 2 deletions test/commands/zookeeper_test.js
Expand Up @@ -32,7 +32,7 @@ describe('kafka:zookeeper', () => {
}

beforeEach(() => {
planName = 'heroku-kafka:beta-private-standard-2'
planName = 'heroku-kafka:private-standard-2'
kafka = nock('https://kafka-api.heroku.com:443')
cli.mockConsole()
cli.exit.mock()
Expand All @@ -44,7 +44,7 @@ describe('kafka:zookeeper', () => {
})

it('warns and exits with an error if used with a non-Private Spaces cluster', () => {
planName = 'heroku-kafka:beta-standard-2'
planName = 'heroku-kafka:standard-2'
return expectExit(1, cmd.run({app: 'myapp', args: { VALUE: 'enable' }}))
.then(() => expect(cli.stdout).to.be.empty)
.then(() => expect(cli.stderr).to.equal(' ▸ `kafka:zookeeper` is only available in Heroku Private Spaces\n'))
Expand Down
18 changes: 9 additions & 9 deletions test/lib/shared_test.js
Expand Up @@ -51,7 +51,7 @@ describe('parseDuration', function () {
})
})

describe('isPrivate', function () {
describe('isZookeeperAllowed', function () {
let cases = [
[ { plan: { name: 'standard-0' } }, false ],
[ { plan: { name: 'standard-1' } }, false ],
Expand All @@ -65,19 +65,19 @@ describe('isPrivate', function () {
[ { plan: { name: 'private-extended-0' } }, true ],
[ { plan: { name: 'private-extended-1' } }, true ],
[ { plan: { name: 'private-extended-2' } }, true ],
[ { plan: { name: 'shield-standard-0' } }, true ],
[ { plan: { name: 'shield-standard-1' } }, true ],
[ { plan: { name: 'shield-standard-2' } }, true ],
[ { plan: { name: 'shield-extended-0' } }, true ],
[ { plan: { name: 'shield-extended-1' } }, true ],
[ { plan: { name: 'shield-extended-2' } }, true ]
[ { plan: { name: 'shield-standard-0' } }, false ],
[ { plan: { name: 'shield-standard-1' } }, false ],
[ { plan: { name: 'shield-standard-2' } }, false ],
[ { plan: { name: 'shield-extended-0' } }, false ],
[ { plan: { name: 'shield-extended-1' } }, false ],
[ { plan: { name: 'shield-extended-2' } }, false ]
]
cases.forEach(function (testcase) {
let addon = testcase[0]
let expected = testcase[1]

it(`considers '${addon.plan.name}' to${expected ? '' : ' not'} be private'`, function () {
let actual = shared.isPrivate(addon)
it(`considers '${addon.plan.name}' to${expected ? '' : ' not'} be allowed to enable zookeeper'`, function () {
let actual = shared.isZookeeperAllowed(addon)
expect(actual).to.equal(expected)
})
})
Expand Down

0 comments on commit 7aab16b

Please sign in to comment.