Skip to content

Commit

Permalink
Update import paths for types
Browse files Browse the repository at this point in the history
  • Loading branch information
justinwilaby committed Apr 8, 2024
1 parent d00e226 commit e9a2105
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 64 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Args} from '@oclif/core'
import heredoc from 'tsheredoc'
import {PGSettingsCommand, type Setting, type SettingKey} from '../../../lib/pg/setter'
import {PGSettingsCommand} from '../../../lib/pg/setter'
import type {Setting, SettingKey} from '../../../lib/pg/types'

export default class LogMinDurationStatement extends PGSettingsCommand {
static description = heredoc(`
Expand All @@ -16,11 +17,11 @@ export default class LogMinDurationStatement extends PGSettingsCommand {

protected settingKey:SettingKey = 'log_min_duration_statement'

protected convertValue(val: number): number {
return val
protected convertValue(val: unknown): number {
return val as number
}

protected explain(setting: Setting) {
protected explain(setting: Setting<unknown>) {
if (setting.value === -1) {
return 'The duration of each completed statement will not be logged.'
}
Expand Down
60 changes: 0 additions & 60 deletions packages/pg-v5/test/unit/commands/settings/settings.unit.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,66 +96,6 @@ describe('pg:settings', () => {
.then(() => expect(cli.stdout).to.equal(`${settingsResultName} is set to ${settingResult.value} for postgres-1.\n${settingResult.values[settingResult.value]}\n`))
})

it('shows settings for auto_explain_log_analyze with value', () => {
setupSettingsMockData('auto_explain.log_analyze')
cmd = proxyquire('../../../../commands/settings/auto_explain_log_analyze', {
settings: proxyquire.noCallThru().load('../../../../lib/setter', {
'./fetcher': fetcher,
}),
})
pg.get('/postgres/v0/databases/1/config').reply(200, settingsResult)
return cmd.run({args: {database: 'test-database', value: ''}, flags: {}})
.then(() => expect(cli.stdout).to.equal('auto-explain.log-analyze is set to test_value for postgres-1.\nEXPLAIN ANALYZE execution plans will be logged.\n'))
})

it('shows settings for auto_explain_log_analyze with no value', () => {
setupSettingsMockData('auto_explain.log_analyze', '')
cmd = proxyquire('../../../../commands/settings/auto_explain_log_analyze', {
settings: proxyquire.noCallThru().load('../../../../lib/setter', {
'./fetcher': fetcher,
}),
})
pg.get('/postgres/v0/databases/1/config').reply(200, settingsResult)
return cmd.run({args: {database: 'test-database', value: ''}, flags: {}})
.then(() => expect(cli.stdout).to.equal('auto-explain.log-analyze is set to for postgres-1.\nEXPLAIN ANALYZE execution plans will not be logged.\n'))
})

it('shows settings for log_min_duration_statement with value', () => {
setupSettingsMockData('log_min_duration_statement')
cmd = proxyquire('../../../../commands/settings/log_min_duration_statement', {
settings: proxyquire.noCallThru().load('../../../../lib/setter', {
'./fetcher': fetcher,
}),
})
pg.get('/postgres/v0/databases/1/config').reply(200, settingsResult)
return cmd.run({args: {database: 'test-database', value: ''}, flags: {}})
.then(() => expect(cli.stdout).to.equal('log-min-duration-statement is set to test_value for postgres-1.\nThe duration of each completed statement will be logged if the statement ran for at least test_value milliseconds.\n'))
})

it('shows settings for log_min_duration_statement with no value', () => {
setupSettingsMockData('log_min_duration_statement', -1)
cmd = proxyquire('../../../../commands/settings/log_min_duration_statement', {
settings: proxyquire.noCallThru().load('../../../../lib/setter', {
'./fetcher': fetcher,
}),
})
pg.get('/postgres/v0/databases/1/config').reply(200, settingsResult)
return cmd.run({args: {database: 'test-database', value: ''}, flags: {}})
.then(() => expect(cli.stdout).to.equal('log-min-duration-statement is set to -1 for postgres-1.\nThe duration of each completed statement will not be logged.\n'))
})

it('shows settings for log_min_duration_statement with value set to 0', () => {
setupSettingsMockData('log_min_duration_statement', 0)
cmd = proxyquire('../../../../commands/settings/log_min_duration_statement', {
settings: proxyquire.noCallThru().load('../../../../lib/setter', {
'./fetcher': fetcher,
}),
})
pg.get('/postgres/v0/databases/1/config').reply(200, settingsResult)
return cmd.run({args: {database: 'test-database', value: ''}, flags: {}})
.then(() => expect(cli.stdout).to.equal('log-min-duration-statement is set to 0 for postgres-1.\nThe duration of each completed statement will be logged.\n'))
})

it('shows settings for auto_explain_log_nested_statements with value', () => {
setupSettingsMockData('auto_explain.log_nested_statements')
cmd = proxyquire('../../../../commands/settings/auto_explain_log_nested_statements', {
Expand Down

0 comments on commit e9a2105

Please sign in to comment.