Skip to content

Commit e73d548

Browse files
author
Kartik Raj
committed
Fix startup telemetry tests
1 parent d905c66 commit e73d548

File tree

1 file changed

+6
-31
lines changed

1 file changed

+6
-31
lines changed

src/test/startupTelemetry.unit.test.ts

Lines changed: 6 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import { expect } from 'chai';
77
import * as TypeMoq from 'typemoq';
8-
import { Uri, WorkspaceConfiguration } from 'vscode';
8+
import { Uri } from 'vscode';
99
import { IWorkspaceService } from '../client/common/application/types';
1010
import { DeprecatePythonPath } from '../client/common/experiments/groups';
1111
import { IExperimentService, IInterpreterPathService } from '../client/common/types';
@@ -28,26 +28,12 @@ suite('Startup Telemetry - hasUserDefinedPythonPath()', async () => {
2828
serviceContainer.setup((s) => s.get(IInterpreterPathService)).returns(() => interpreterPathService.object);
2929
});
3030

31-
function setupConfigProvider(): TypeMoq.IMock<WorkspaceConfiguration> {
32-
const workspaceConfig = TypeMoq.Mock.ofType<WorkspaceConfiguration>();
33-
workspaceService
34-
.setup((w) => w.getConfiguration(TypeMoq.It.isValue('python'), TypeMoq.It.isValue(resource)))
35-
.returns(() => workspaceConfig.object);
36-
return workspaceConfig;
37-
}
38-
3931
[undefined, 'python'].forEach((globalValue) => {
4032
[undefined, 'python'].forEach((workspaceValue) => {
4133
[undefined, 'python'].forEach((workspaceFolderValue) => {
4234
test(`Return false if using settings equals {globalValue: ${globalValue}, workspaceValue: ${workspaceValue}, workspaceFolderValue: ${workspaceFolderValue}}`, () => {
43-
experimentsManager
44-
.setup((e) => e.inExperimentSync(DeprecatePythonPath.experiment))
45-
.returns(() => false);
46-
const workspaceConfig = setupConfigProvider();
47-
48-
workspaceConfig
49-
.setup((w) => w.inspect('pythonPath'))
50-
35+
interpreterPathService
36+
.setup((i) => i.inspect(resource))
5137
.returns(() => ({ globalValue, workspaceValue, workspaceFolderValue } as any));
5238
const result = hasUserDefinedPythonPath(resource, serviceContainer.object);
5339
expect(result).to.equal(false, 'Should be false');
@@ -57,21 +43,10 @@ suite('Startup Telemetry - hasUserDefinedPythonPath()', async () => {
5743
});
5844

5945
test('Return true if using setting value equals something else', () => {
60-
experimentsManager.setup((e) => e.inExperimentSync(DeprecatePythonPath.experiment)).returns(() => false);
61-
const workspaceConfig = setupConfigProvider();
62-
63-
workspaceConfig.setup((w) => w.inspect('pythonPath')).returns(() => ({ globalValue: 'something else' } as any));
64-
const result = hasUserDefinedPythonPath(resource, serviceContainer.object);
65-
expect(result).to.equal(true, 'Should be true');
66-
});
67-
68-
test('If in Deprecate PythonPath experiment, use the new API to inspect settings', () => {
69-
experimentsManager.setup((e) => e.inExperimentSync(DeprecatePythonPath.experiment)).returns(() => true);
7046
interpreterPathService
7147
.setup((i) => i.inspect(resource))
72-
.returns(() => ({}))
73-
.verifiable(TypeMoq.Times.once());
74-
hasUserDefinedPythonPath(resource, serviceContainer.object);
75-
interpreterPathService.verifyAll();
48+
.returns(() => ({ globalValue: 'something else' } as any));
49+
const result = hasUserDefinedPythonPath(resource, serviceContainer.object);
50+
expect(result).to.equal(true, 'Should be true');
7651
});
7752
});

0 commit comments

Comments
 (0)