-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add explain postgres data connectors setting
- Loading branch information
Showing
3 changed files
with
80 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
packages/cli/src/commands/pg/settings/explain-data-connector-details.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import {flags} from '@heroku-cli/command' | ||
import {Args} from '@oclif/core' | ||
import heredoc from 'tsheredoc' | ||
import {type BooleanAsString, booleanConverter, PGSettingsCommand} from '../../../lib/pg/setter' | ||
import type {Setting, SettingKey} from '../../../lib/pg/types' | ||
|
||
export default class ExplainDataConnectorDetails extends PGSettingsCommand { | ||
static topic = 'pg' | ||
static description = heredoc(` | ||
Displays stats on replication slots on your database. The default value is "off". | ||
`) | ||
|
||
static flags = { | ||
app: flags.app({required: true}), | ||
remote: flags.remote(), | ||
} | ||
|
||
static args = { | ||
database: Args.string(), | ||
value: Args.string(), | ||
} | ||
|
||
protected settingKey:SettingKey = 'explain_data_connector_details' | ||
|
||
protected convertValue(val: BooleanAsString): boolean { | ||
return booleanConverter(val) | ||
} | ||
|
||
protected explain(setting: Setting<boolean>): string { | ||
if (setting?.value) { | ||
return 'Data replication slot details will be logged.' | ||
} | ||
|
||
return 'Data replication slot details will no longer be logged.' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
packages/cli/test/unit/commands/pg/settings/explain-data-connector-details.unit.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import {expect} from '@oclif/test' | ||
import * as nock from 'nock' | ||
import {stdout} from 'stdout-stderr' | ||
import heredoc from 'tsheredoc' | ||
import runCommand from '../../../../helpers/runCommand' | ||
import Cmd from '../../../../../src/commands/pg/settings/explain-data-connector-details' | ||
import * as fixtures from '../../../../fixtures/addons/fixtures' | ||
|
||
describe('pg:explain-data-connector-details', function () { | ||
const addon = fixtures.addons['dwh-db'] | ||
|
||
beforeEach(function () { | ||
nock('https://api.heroku.com') | ||
.post('/actions/addons/resolve', { | ||
app: 'myapp', | ||
addon: 'test-database', | ||
}).reply(200, [addon]) | ||
}) | ||
|
||
afterEach(function () { | ||
nock.cleanAll() | ||
}) | ||
|
||
it('turns on explain-data-connector-details option', async function () { | ||
nock('https://api.data.heroku.com') | ||
.get(`/postgres/v0/databases/${addon.id}/config`).reply(200, {explain_data_connector_details: {value: 'on'}}) | ||
await runCommand(Cmd, ['--app', 'myapp', 'test-database']) | ||
expect(stdout.output).to.equal(heredoc(` | ||
explain-data-connector-details is set to on for ${addon.name}. | ||
Data replication slot details will be logged. | ||
`)) | ||
}) | ||
|
||
it('turns off explain-data-connector-details option', async function () { | ||
nock('https://api.data.heroku.com') | ||
.get(`/postgres/v0/databases/${addon.id}/config`).reply(200, {explain_data_connector_details: {value: ''}}) | ||
await runCommand(Cmd, ['--app', 'myapp', 'test-database']) | ||
expect(stdout.output).to.equal(heredoc(` | ||
explain-data-connector-details is set to for ${addon.name}. | ||
Data replication slot details will no longer be logged. | ||
`)) | ||
}) | ||
}) |