-
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
70 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(` | ||
UNICORN, do things | ||
`) | ||
|
||
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 'SETTING ON DOES THINGS' | ||
} | ||
|
||
return 'SETTING OFF DOES THINGS' | ||
} | ||
} |
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
33 changes: 33 additions & 0 deletions
33
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,33 @@ | ||
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('shows settings for auto_explain with value', 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}. | ||
SETTING ON DOES THINGS | ||
`)) | ||
}) | ||
}) |