Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/commands/redis/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export default class Cli extends Command {
}

const useTls = preferNativeTls || !hobby
const portOffset = hobby ? undefined : 1
const portOffset = preferNativeTls || hobby ? undefined : 1
const client = this.createDirectConnection(uri, {portOffset, useTls})
return redisCLI(uri, client)
}
Expand Down
9 changes: 9 additions & 0 deletions test/unit/commands/redis/cli.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const addonId = '1dcb269b-8be5-4132-8aeb-e3f3c7364958'
const appId = '7b0ae612-8775-4502-a5b5-2b45a4d18b2d'

const connectionTypes: string[] = []
const portOffsets: (number | undefined)[] = []

class TestCli extends Cmd {
protected override async createBastionConnection() {
Expand All @@ -29,6 +30,7 @@ class TestCli extends Cmd {

protected override createDirectConnection(_uri: URL, options: {portOffset?: number, useTls: boolean}) {
connectionTypes.push(options.useTls ? 'tls' : 'net')
portOffsets.push(options.portOffset)
return new Client() as unknown as ReturnType<Cmd['createDirectConnection']>
}
}
Expand All @@ -43,6 +45,7 @@ describe('heroku redis:cli', function () {
describe('connection tests', function () {
beforeEach(function () {
connectionTypes.length = 0
portOffsets.length = 0
})

it('# for hobby it uses net.connect', async function () {
Expand Down Expand Up @@ -81,6 +84,8 @@ describe('heroku redis:cli', function () {
expect(outputParts[1]).to.equal('')
expect(outputParts[2]).to.equal('Disconnected from instance.')
expect(connectionTypes).to.include('net')
expect(portOffsets).to.have.lengthOf(1)
expect(portOffsets[0]).to.equal(undefined)
})

it('# for hobby it uses TLS if prefer_native_tls', async function () {
Expand Down Expand Up @@ -119,6 +124,8 @@ describe('heroku redis:cli', function () {
expect(outputParts[1]).to.equal('')
expect(outputParts[2]).to.equal('Disconnected from instance.')
expect(connectionTypes).to.include('tls')
expect(portOffsets).to.have.lengthOf(1)
expect(portOffsets[0]).to.equal(undefined)
})

it('# for premium it uses tls.connect', async function () {
Expand Down Expand Up @@ -157,6 +164,8 @@ describe('heroku redis:cli', function () {
expect(outputParts[1]).to.equal('')
expect(outputParts[2]).to.equal('Disconnected from instance.')
expect(connectionTypes).to.include('tls')
expect(portOffsets).to.have.lengthOf(1)
expect(portOffsets[0]).to.equal(1)
})

it('# for bastion it uses tunnel', async function () {
Expand Down
Loading