From 44e992b2e5d61978e8ec6ed53576d9f631261e9f Mon Sep 17 00:00:00 2001 From: Piotr Kukielka Date: Wed, 6 Nov 2024 14:40:58 +0100 Subject: [PATCH] Fix configuration inspect method --- 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(