Skip to content

Commit

Permalink
Fix configuration inspect method
Browse files Browse the repository at this point in the history
  • Loading branch information
pkukielka committed Nov 6, 2024
1 parent 836693e commit 44e992b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
22 changes: 20 additions & 2 deletions agent/src/AgentWorkspaceConfiguration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,26 @@ describe('AgentWorkspaceConfiguration', () => {
})

describe('inspect', () => {
it('returns undefined for any section', () => {
expect(config.inspect('cody.serverEndpoint')).toBeUndefined()
it('returns correct values for existing section', () => {
expect(config.inspect('cody.serverEndpoint')).toStrictEqual({
defaultValue: undefined,
globalValue: 'https://sourcegraph.test',
key: 'cody.serverEndpoint',
workspaceValue: 'https://sourcegraph.test',
})
})

it('returns correct default values for pre-defined properties', () => {
expect(config.inspect('cody.commandCodeLenses')).toStrictEqual({
defaultValue: false,
globalValue: false,
key: 'cody.commandCodeLenses',
workspaceValue: false,
})
})

it('returns undefined for not defined properties', () => {
expect(config.inspect('some.undefined.value')).toStrictEqual(undefined)
})
})

Expand Down
11 changes: 10 additions & 1 deletion agent/src/AgentWorkspaceConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,16 @@ export class AgentWorkspaceConfiguration implements vscode.WorkspaceConfiguratio
languageIds?: string[] | undefined
}
| undefined {
return undefined
const value = this.get(section)
if (value === undefined) {
return undefined
}
return {
key: section,
defaultValue: defaultConfigurationValue(section),
globalValue: value,
workspaceValue: value,
}
}

public async update(
Expand Down

0 comments on commit 44e992b

Please sign in to comment.