From e66359aba6f60eda40608157fafbba65aaae6e1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Kukie=C5=82ka?= Date: Wed, 6 Nov 2024 15:31:09 +0100 Subject: [PATCH] Fix configuration inspect method (#6075) ## Test plan Unit tests added. Also test plan from this PR: https://github.com/sourcegraph/cody/pull/6058 should work without any settings on the instance. --- agent/src/AgentWorkspaceConfiguration.test.ts | 22 +++++++++++++++++-- agent/src/AgentWorkspaceConfiguration.ts | 11 +++++++++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/agent/src/AgentWorkspaceConfiguration.test.ts b/agent/src/AgentWorkspaceConfiguration.test.ts index 845d623800d..698302fceb2 100644 --- a/agent/src/AgentWorkspaceConfiguration.test.ts +++ b/agent/src/AgentWorkspaceConfiguration.test.ts @@ -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) }) }) diff --git a/agent/src/AgentWorkspaceConfiguration.ts b/agent/src/AgentWorkspaceConfiguration.ts index 778611cb6bb..7e86332946e 100644 --- a/agent/src/AgentWorkspaceConfiguration.ts +++ b/agent/src/AgentWorkspaceConfiguration.ts @@ -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(