From e7d3de93c4f2a0163698335418982c52b33c63ce Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Thu, 6 Jan 2022 18:40:11 +0530 Subject: [PATCH] Fix startup telemetry tests --- src/test/startupTelemetry.unit.test.ts | 31 ++++++-------------------- 1 file changed, 7 insertions(+), 24 deletions(-) diff --git a/src/test/startupTelemetry.unit.test.ts b/src/test/startupTelemetry.unit.test.ts index ef79039c75baa..73cbbd00492eb 100644 --- a/src/test/startupTelemetry.unit.test.ts +++ b/src/test/startupTelemetry.unit.test.ts @@ -5,7 +5,7 @@ import { expect } from 'chai'; import * as TypeMoq from 'typemoq'; -import { Uri, WorkspaceConfiguration } from 'vscode'; +import { Uri } from 'vscode'; import { IWorkspaceService } from '../client/common/application/types'; import { DeprecatePythonPath } from '../client/common/experiments/groups'; import { IExperimentService, IInterpreterPathService } from '../client/common/types'; @@ -28,26 +28,12 @@ suite('Startup Telemetry - hasUserDefinedPythonPath()', async () => { serviceContainer.setup((s) => s.get(IInterpreterPathService)).returns(() => interpreterPathService.object); }); - function setupConfigProvider(): TypeMoq.IMock { - const workspaceConfig = TypeMoq.Mock.ofType(); - workspaceService - .setup((w) => w.getConfiguration(TypeMoq.It.isValue('python'), TypeMoq.It.isValue(resource))) - .returns(() => workspaceConfig.object); - return workspaceConfig; - } - [undefined, 'python'].forEach((globalValue) => { [undefined, 'python'].forEach((workspaceValue) => { [undefined, 'python'].forEach((workspaceFolderValue) => { test(`Return false if using settings equals {globalValue: ${globalValue}, workspaceValue: ${workspaceValue}, workspaceFolderValue: ${workspaceFolderValue}}`, () => { - experimentsManager - .setup((e) => e.inExperimentSync(DeprecatePythonPath.experiment)) - .returns(() => false); - const workspaceConfig = setupConfigProvider(); - - workspaceConfig - .setup((w) => w.inspect('pythonPath')) - + interpreterPathService + .setup((i) => i.inspect(resource)) .returns(() => ({ globalValue, workspaceValue, workspaceFolderValue } as any)); const result = hasUserDefinedPythonPath(resource, serviceContainer.object); expect(result).to.equal(false, 'Should be false'); @@ -58,19 +44,16 @@ suite('Startup Telemetry - hasUserDefinedPythonPath()', async () => { test('Return true if using setting value equals something else', () => { experimentsManager.setup((e) => e.inExperimentSync(DeprecatePythonPath.experiment)).returns(() => false); - const workspaceConfig = setupConfigProvider(); - - workspaceConfig.setup((w) => w.inspect('pythonPath')).returns(() => ({ globalValue: 'something else' } as any)); + interpreterPathService + .setup((i) => i.inspect(resource)) + .returns(() => ({ globalValue: 'something else' } as any)); const result = hasUserDefinedPythonPath(resource, serviceContainer.object); expect(result).to.equal(true, 'Should be true'); }); test('If in Deprecate PythonPath experiment, use the new API to inspect settings', () => { experimentsManager.setup((e) => e.inExperimentSync(DeprecatePythonPath.experiment)).returns(() => true); - interpreterPathService - .setup((i) => i.inspect(resource)) - .returns(() => ({})) - .verifiable(TypeMoq.Times.once()); + interpreterPathService.setup((i) => i.inspect(resource)).returns(() => ({})); hasUserDefinedPythonPath(resource, serviceContainer.object); interpreterPathService.verifyAll(); });