Skip to content

Commit 31abb9b

Browse files
committed
Remove stubbing of areSameEnvironment
1 parent 9e438bc commit 31abb9b

File tree

1 file changed

+12
-20
lines changed

1 file changed

+12
-20
lines changed

src/test/pythonEnvironments/base/envsCache.unit.test.ts

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,33 +5,26 @@ import * as assert from 'assert';
55
import * as sinon from 'sinon';
66
import { PythonEnvInfoCache } from '../../../client/pythonEnvironments/base/envsCache';
77
import { PythonEnvInfo, PythonEnvKind } from '../../../client/pythonEnvironments/base/info';
8-
import * as envInfo from '../../../client/pythonEnvironments/base/info/env';
98
import * as externalDependencies from '../../../client/pythonEnvironments/common/externalDependencies';
109

1110
suite('Environment Info cache', () => {
1211
let getGlobalPersistentStoreStub: sinon.SinonStub;
13-
let areSameEnvironmentStub: sinon.SinonStub;
1412
let updatedValues: PythonEnvInfo[] | undefined;
1513

1614
const allEnvsComplete = () => true;
1715
const envInfoArray = [
1816
{
19-
kind: PythonEnvKind.Conda, name: 'my-conda-env', defaultDisplayName: 'env-one',
17+
kind: PythonEnvKind.Conda, executable: { filename: 'my-conda-env' },
2018
},
2119
{
22-
kind: PythonEnvKind.Venv, name: 'my-venv-env', defaultDisplayName: 'env-two',
20+
kind: PythonEnvKind.Venv, executable: { filename: 'my-venv-env' },
2321
},
2422
{
25-
kind: PythonEnvKind.Pyenv, name: 'my-pyenv-env', defaultDisplayName: 'env-three',
23+
kind: PythonEnvKind.Pyenv, executable: { filename: 'my-pyenv-env' },
2624
},
2725
] as PythonEnvInfo[];
2826

2927
setup(() => {
30-
areSameEnvironmentStub = sinon.stub(envInfo, 'areSameEnvironment');
31-
areSameEnvironmentStub.callsFake(
32-
(env1: PythonEnvInfo, env2:PythonEnvInfo) => env1.name === env2.name,
33-
);
34-
3528
getGlobalPersistentStoreStub = sinon.stub(externalDependencies, 'getGlobalPersistentStore');
3629
getGlobalPersistentStoreStub.returns({
3730
get() { return envInfoArray; },
@@ -44,7 +37,6 @@ suite('Environment Info cache', () => {
4437

4538
teardown(() => {
4639
getGlobalPersistentStoreStub.restore();
47-
areSameEnvironmentStub.restore();
4840
updatedValues = undefined;
4941
});
5042

@@ -96,23 +88,23 @@ suite('Environment Info cache', () => {
9688
});
9789

9890
test('`filterEnvs` should return environments that match its argument using areSameEnvironmnet', () => {
99-
const env:PythonEnvInfo = { name: 'my-venv-env' } as unknown as PythonEnvInfo;
91+
const env:PythonEnvInfo = { executable: { filename: 'my-venv-env' } } as unknown as PythonEnvInfo;
10092
const envsCache = new PythonEnvInfoCache(allEnvsComplete);
10193

10294
envsCache.initialize();
10395

10496
const result = envsCache.filterEnvs(env);
10597

10698
assert.deepStrictEqual(result, [{
107-
kind: PythonEnvKind.Venv, name: 'my-venv-env', defaultDisplayName: 'env-two',
99+
kind: PythonEnvKind.Venv, executable: { filename: 'my-venv-env' },
108100
}]);
109101
});
110102

111103
test('`filterEnvs` should return a deep copy of the matched environments', () => {
112104
const envToFind = {
113-
kind: PythonEnvKind.System, name: 'my-system-env', defaultDisplayName: 'env-system',
105+
kind: PythonEnvKind.System, executable: { filename: 'my-system-env' },
114106
} as unknown as PythonEnvInfo;
115-
const env:PythonEnvInfo = { name: 'my-system-env' } as unknown as PythonEnvInfo;
107+
const env:PythonEnvInfo = { executable: { filename: 'my-system-env' } } as unknown as PythonEnvInfo;
116108
const envsCache = new PythonEnvInfoCache(allEnvsComplete);
117109

118110
envsCache.setAllEnvs([...envInfoArray, envToFind]);
@@ -124,7 +116,7 @@ suite('Environment Info cache', () => {
124116
});
125117

126118
test('`filterEnvs` should return an empty array if no environment matches the properties of its argument', () => {
127-
const env:PythonEnvInfo = { name: 'my-nonexistent-env' } as unknown as PythonEnvInfo;
119+
const env:PythonEnvInfo = { executable: { filename: 'my-nonexistent-env' } } as unknown as PythonEnvInfo;
128120
const envsCache = new PythonEnvInfoCache(allEnvsComplete);
129121

130122
envsCache.initialize();
@@ -135,7 +127,7 @@ suite('Environment Info cache', () => {
135127
});
136128

137129
test('`filterEnvs` should return undefined if the cache hasn\'t been initialized', () => {
138-
const env:PythonEnvInfo = { name: 'my-nonexistent-env' } as unknown as PythonEnvInfo;
130+
const env:PythonEnvInfo = { executable: { filename: 'my-nonexistent-env' } } as unknown as PythonEnvInfo;
139131
const envsCache = new PythonEnvInfoCache(allEnvsComplete);
140132

141133
const result = envsCache.filterEnvs(env);
@@ -146,11 +138,11 @@ suite('Environment Info cache', () => {
146138
test('`flush` should write complete environment info objects to persistent storage', async () => {
147139
const otherEnv = {
148140
kind: PythonEnvKind.OtherGlobal,
149-
name: 'my-other-env',
150-
defaultDisplayName: 'env-five',
141+
executable: { filename: 'my-other-env' },
142+
defaultDisplayName: 'other-env',
151143
};
152144
const updatedEnvInfoArray = [
153-
otherEnv, { kind: PythonEnvKind.System, name: 'my-system-env' },
145+
otherEnv, { kind: PythonEnvKind.System, executable: { filename: 'my-system-env' } },
154146
] as PythonEnvInfo[];
155147
const expected = [
156148
otherEnv,

0 commit comments

Comments
 (0)