-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
migrate(W-14179873): pg-v5: Upgrade pg:settings:auto-explain:log-verbose
- Loading branch information
1 parent
f455e4f
commit 9593543
Showing
5 changed files
with
81 additions
and
48 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
packages/cli/src/commands/pg/settings/auto-explain/log-verbose.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,35 @@ | ||
import {flags} from '@heroku-cli/command' | ||
import {Args} from '@oclif/core' | ||
import heredoc from 'tsheredoc' | ||
import {booleanConverter, PGSettingsCommand, type Setting, type SettingKey} from '../../../../lib/pg/setter' | ||
|
||
export default class AutoExplainLogVerbose extends PGSettingsCommand { | ||
static topic = 'pg' | ||
static description = heredoc( | ||
`Include verbose details in execution plans. | ||
This is equivalent to calling EXPLAIN VERBOSE.`) | ||
|
||
static flags = { | ||
app: flags.app({required: true}), | ||
remote: flags.remote(), | ||
} | ||
|
||
static args = { | ||
database: Args.string(), | ||
value: Args.string(), | ||
} | ||
|
||
protected settingKey: SettingKey = 'auto_explain.log_verbose' | ||
|
||
protected explain(setting: Setting) { | ||
if (setting.value) { | ||
return 'Verbose execution plan logging has been enabled for auto_explain.' | ||
} | ||
|
||
return 'Verbose execution plan logging has been disabled for auto_explain.' | ||
} | ||
|
||
protected convertValue(val: boolean): boolean { | ||
return booleanConverter(val) | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
packages/cli/test/unit/commands/pg/settings/auto-explain/log-verbose.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,46 @@ | ||
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/auto-explain/log-verbose' | ||
import * as fixtures from '../../../../../fixtures/addons/fixtures' | ||
|
||
describe('pg:settings:auto-explain:log-verbose', () => { | ||
let api: nock.Scope | ||
let pg: nock.Scope | ||
const addon = fixtures.addons['dwh-db'] | ||
|
||
beforeEach(() => { | ||
api = nock('https://api.heroku.com') | ||
api.post('/actions/addons/resolve', { | ||
app: 'myapp', | ||
addon: 'test-database', | ||
}).reply(200, [addon]) | ||
|
||
pg = nock('https://api.data.heroku.com') | ||
}) | ||
|
||
afterEach(() => { | ||
api.done() | ||
pg.done() | ||
}) | ||
|
||
it('shows settings for auto_explain_log_verbose with value', async () => { | ||
pg.get(`/postgres/v0/databases/${addon.id}/config`).reply(200, {'auto_explain.log_verbose': {value: 'test_value'}}) | ||
await runCommand(Cmd, ['--app', 'myapp', 'test-database']) | ||
expect(stdout.output).to.equal(heredoc(` | ||
auto-explain.log-verbose is set to test_value for ${addon.name}. | ||
Verbose execution plan logging has been enabled for auto_explain. | ||
`)) | ||
}) | ||
|
||
it('shows settings for auto_explain_log_verbose with no value', async () => { | ||
pg.get(`/postgres/v0/databases/${addon.id}/config`).reply(200, {'auto_explain.log_verbose': {value: ''}}) | ||
await runCommand(Cmd, ['--app', 'myapp', 'test-database']) | ||
expect(stdout.output).to.equal(heredoc(` | ||
auto-explain.log-verbose is set to for ${addon.name}. | ||
Verbose execution plan logging has been disabled for auto_explain. | ||
`)) | ||
}) | ||
}) |
23 changes: 0 additions & 23 deletions
23
packages/pg-v5/commands/settings/auto_explain_log_verbose.js
This file was deleted.
Oops, something went wrong.
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
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