@@ -5,33 +5,26 @@ import * as assert from 'assert';
5
5
import * as sinon from 'sinon' ;
6
6
import { PythonEnvInfoCache } from '../../../client/pythonEnvironments/base/envsCache' ;
7
7
import { PythonEnvInfo , PythonEnvKind } from '../../../client/pythonEnvironments/base/info' ;
8
- import * as envInfo from '../../../client/pythonEnvironments/base/info/env' ;
9
8
import * as externalDependencies from '../../../client/pythonEnvironments/common/externalDependencies' ;
10
9
11
10
suite ( 'Environment Info cache' , ( ) => {
12
11
let getGlobalPersistentStoreStub : sinon . SinonStub ;
13
- let areSameEnvironmentStub : sinon . SinonStub ;
14
12
let updatedValues : PythonEnvInfo [ ] | undefined ;
15
13
16
14
const allEnvsComplete = ( ) => true ;
17
15
const envInfoArray = [
18
16
{
19
- kind : PythonEnvKind . Conda , name : 'my-conda-env' , defaultDisplayName : 'env-one' ,
17
+ kind : PythonEnvKind . Conda , executable : { filename : 'my-conda-env' } ,
20
18
} ,
21
19
{
22
- kind : PythonEnvKind . Venv , name : 'my-venv-env' , defaultDisplayName : 'env-two' ,
20
+ kind : PythonEnvKind . Venv , executable : { filename : 'my-venv-env' } ,
23
21
} ,
24
22
{
25
- kind : PythonEnvKind . Pyenv , name : 'my-pyenv-env' , defaultDisplayName : 'env-three' ,
23
+ kind : PythonEnvKind . Pyenv , executable : { filename : 'my-pyenv-env' } ,
26
24
} ,
27
25
] as PythonEnvInfo [ ] ;
28
26
29
27
setup ( ( ) => {
30
- areSameEnvironmentStub = sinon . stub ( envInfo , 'areSameEnvironment' ) ;
31
- areSameEnvironmentStub . callsFake (
32
- ( env1 : PythonEnvInfo , env2 :PythonEnvInfo ) => env1 . name === env2 . name ,
33
- ) ;
34
-
35
28
getGlobalPersistentStoreStub = sinon . stub ( externalDependencies , 'getGlobalPersistentStore' ) ;
36
29
getGlobalPersistentStoreStub . returns ( {
37
30
get ( ) { return envInfoArray ; } ,
@@ -44,7 +37,6 @@ suite('Environment Info cache', () => {
44
37
45
38
teardown ( ( ) => {
46
39
getGlobalPersistentStoreStub . restore ( ) ;
47
- areSameEnvironmentStub . restore ( ) ;
48
40
updatedValues = undefined ;
49
41
} ) ;
50
42
@@ -96,23 +88,23 @@ suite('Environment Info cache', () => {
96
88
} ) ;
97
89
98
90
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 ;
100
92
const envsCache = new PythonEnvInfoCache ( allEnvsComplete ) ;
101
93
102
94
envsCache . initialize ( ) ;
103
95
104
96
const result = envsCache . filterEnvs ( env ) ;
105
97
106
98
assert . deepStrictEqual ( result , [ {
107
- kind : PythonEnvKind . Venv , name : 'my-venv-env' , defaultDisplayName : 'env-two' ,
99
+ kind : PythonEnvKind . Venv , executable : { filename : 'my-venv-env' } ,
108
100
} ] ) ;
109
101
} ) ;
110
102
111
103
test ( '`filterEnvs` should return a deep copy of the matched environments' , ( ) => {
112
104
const envToFind = {
113
- kind : PythonEnvKind . System , name : 'my-system-env' , defaultDisplayName : 'env-system' ,
105
+ kind : PythonEnvKind . System , executable : { filename : 'my-system-env' } ,
114
106
} 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 ;
116
108
const envsCache = new PythonEnvInfoCache ( allEnvsComplete ) ;
117
109
118
110
envsCache . setAllEnvs ( [ ...envInfoArray , envToFind ] ) ;
@@ -124,7 +116,7 @@ suite('Environment Info cache', () => {
124
116
} ) ;
125
117
126
118
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 ;
128
120
const envsCache = new PythonEnvInfoCache ( allEnvsComplete ) ;
129
121
130
122
envsCache . initialize ( ) ;
@@ -135,7 +127,7 @@ suite('Environment Info cache', () => {
135
127
} ) ;
136
128
137
129
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 ;
139
131
const envsCache = new PythonEnvInfoCache ( allEnvsComplete ) ;
140
132
141
133
const result = envsCache . filterEnvs ( env ) ;
@@ -146,11 +138,11 @@ suite('Environment Info cache', () => {
146
138
test ( '`flush` should write complete environment info objects to persistent storage' , async ( ) => {
147
139
const otherEnv = {
148
140
kind : PythonEnvKind . OtherGlobal ,
149
- name : 'my-other-env' ,
150
- defaultDisplayName : 'env-five ' ,
141
+ executable : { filename : 'my-other-env' } ,
142
+ defaultDisplayName : 'other-env ' ,
151
143
} ;
152
144
const updatedEnvInfoArray = [
153
- otherEnv , { kind : PythonEnvKind . System , name : 'my-system-env' } ,
145
+ otherEnv , { kind : PythonEnvKind . System , executable : { filename : 'my-system-env' } } ,
154
146
] as PythonEnvInfo [ ] ;
155
147
const expected = [
156
148
otherEnv ,
0 commit comments