Skip to content

Commit bd7c5bd

Browse files
author
Kartik Raj
committed
Fix tests
1 parent 4396943 commit bd7c5bd

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

src/client/proposedApi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { IConfigurationService, IDisposableRegistry, IExtensions, IInterpreterPa
88
import { Architecture } from './common/utils/platform';
99
import { IServiceContainer } from './ioc/types';
1010
import {
11-
ActiveEnvironmentIdChangeEvent,
11+
ActiveEnvironmentPathChangeEvent,
1212
Environment,
1313
EnvironmentsChangeEvent,
1414
ProposedExtensionAPI,
@@ -38,7 +38,7 @@ type ActiveEnvironmentChangeEvent = {
3838
path: string;
3939
};
4040

41-
const onDidActiveInterpreterChangedEvent = new EventEmitter<ActiveEnvironmentIdChangeEvent>();
41+
const onDidActiveInterpreterChangedEvent = new EventEmitter<ActiveEnvironmentPathChangeEvent>();
4242
export function reportActiveInterpreterChanged(e: ActiveEnvironmentChangeEvent): void {
4343
onDidActiveInterpreterChangedEvent.fire({ id: getEnvID(e.path), path: e.path, resource: e.resource });
4444
reportActiveInterpreterChangedDeprecated({ path: e.path, resource: e.resource?.uri });

src/client/proposedApiTypes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export interface ProposedExtensionAPI {
2727
/**
2828
* This event is triggered when the active environment setting changes.
2929
*/
30-
readonly onDidChangeActiveEnvironmentPath: Event<ActiveEnvironmentIdChangeEvent>;
30+
readonly onDidChangeActiveEnvironmentPath: Event<ActiveEnvironmentPathChangeEvent>;
3131
/**
3232
* Carries environments found by the extension at the time of fetching the property. Note this may not
3333
* contain all environments in the system as a refresh might be going on.
@@ -177,7 +177,7 @@ export type EnvironmentsChangeEvent = {
177177
readonly type: 'add' | 'remove' | 'update';
178178
};
179179

180-
export type ActiveEnvironmentIdChangeEvent = EnvironmentPath & {
180+
export type ActiveEnvironmentPathChangeEvent = EnvironmentPath & {
181181
/**
182182
* Workspace folder the environment changed for.
183183
*/

src/test/proposedApi.unit.test.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ import { Architecture } from '../client/common/utils/platform';
2828
import { PythonEnvCollectionChangedEvent } from '../client/pythonEnvironments/base/watcher';
2929
import { normCasePath } from '../client/common/platform/fs-paths';
3030
import {
31-
ActiveEnvironmentIdChangeEvent,
31+
ActiveEnvironmentPathChangeEvent,
32+
EnvironmentPath,
3233
EnvironmentsChangeEvent,
3334
ProposedExtensionAPI,
3435
} from '../client/proposedApiTypes';
@@ -74,7 +75,7 @@ suite('Proposed Extension API', () => {
7475
});
7576

7677
test('Provide an event to track when active environment details change', async () => {
77-
const events: ActiveEnvironmentIdChangeEvent[] = [];
78+
const events: ActiveEnvironmentPathChangeEvent[] = [];
7879
proposed.environment.onDidChangeActiveEnvironmentPath((e) => {
7980
events.push(e);
8081
});
@@ -91,7 +92,11 @@ suite('Proposed Extension API', () => {
9192
.setup((c) => c.getSettings(undefined))
9293
.returns(() => (({ pythonPath } as unknown) as IPythonSettings));
9394
const actual = proposed.environment.getActiveEnvironmentPath();
94-
assert.deepEqual(actual, { id: normCasePath(pythonPath), path: pythonPath });
95+
assert.deepEqual(actual, ({
96+
id: normCasePath(pythonPath),
97+
path: pythonPath,
98+
pathType: 'interpreterPath',
99+
} as unknown) as EnvironmentPath);
95100
});
96101

97102
test('getActiveEnvironmentPath: default python', () => {
@@ -100,7 +105,11 @@ suite('Proposed Extension API', () => {
100105
.setup((c) => c.getSettings(undefined))
101106
.returns(() => (({ pythonPath } as unknown) as IPythonSettings));
102107
const actual = proposed.environment.getActiveEnvironmentPath();
103-
assert.deepEqual(actual, { id: 'DEFAULT_PYTHON', path: pythonPath });
108+
assert.deepEqual(actual, ({
109+
id: 'DEFAULT_PYTHON',
110+
path: pythonPath,
111+
pathType: 'interpreterPath',
112+
} as unknown) as EnvironmentPath);
104113
});
105114

106115
test('getActiveEnvironmentPath: With resource', () => {
@@ -110,7 +119,11 @@ suite('Proposed Extension API', () => {
110119
.setup((c) => c.getSettings(resource))
111120
.returns(() => (({ pythonPath } as unknown) as IPythonSettings));
112121
const actual = proposed.environment.getActiveEnvironmentPath(resource);
113-
assert.deepEqual(actual, { id: normCasePath(pythonPath), path: pythonPath });
122+
assert.deepEqual(actual, ({
123+
id: normCasePath(pythonPath),
124+
path: pythonPath,
125+
pathType: 'interpreterPath',
126+
} as unknown) as EnvironmentPath);
114127
});
115128

116129
test('resolveEnvironment: invalid environment (when passed as string)', async () => {

0 commit comments

Comments
 (0)