@@ -170,6 +170,59 @@ suite('Terminal Environment Activation conda', () => {
170
170
expect ( activationCommands ) . to . deep . equal ( expected , 'Incorrect Activation command' ) ;
171
171
} ) ;
172
172
173
+ const interpreterPath = path . join ( 'path' , 'to' , 'interpreter' ) ;
174
+ const environmentName = 'Env' ;
175
+ const environmentNameHasSpaces = 'Env with spaces' ;
176
+ const testsForActivationUsingInterpreterPath =
177
+ [
178
+ {
179
+ testName : 'Activation provides correct activation commands (windows) after 4.4.0 given interpreter path is provided, with no spaces in env name' ,
180
+ envName : environmentName ,
181
+ expectedResult : [ 'path/to/activate' , 'conda activate Env' ] ,
182
+ isWindows : true
183
+ } ,
184
+ {
185
+ testName : 'Activation provides correct activation commands (non-windows) after 4.4.0 given interpreter path is provided, with no spaces in env name' ,
186
+ envName : environmentName ,
187
+ expectedResult : [ 'source path/to/activate' , 'conda activate Env' ] ,
188
+ isWindows : false
189
+ } ,
190
+ {
191
+ testName : 'Activation provides correct activation commands (windows) after 4.4.0 given interpreter path is provided, with spaces in env name' ,
192
+ envName : environmentNameHasSpaces ,
193
+ expectedResult : [ 'path/to/activate' , 'conda activate \"Env with spaces\"' ] ,
194
+ isWindows : true
195
+ } ,
196
+ {
197
+ testName : 'Activation provides correct activation commands (non-windows) after 4.4.0 given interpreter path is provided, with spaces in env name' ,
198
+ envName : environmentNameHasSpaces ,
199
+ expectedResult : [ 'source path/to/activate' , 'conda activate \"Env with spaces\"' ] ,
200
+ isWindows : false
201
+ }
202
+ ] ;
203
+
204
+ testsForActivationUsingInterpreterPath . forEach ( ( testParams ) => {
205
+ test ( testParams . testName , async ( ) => {
206
+ const pythonPath = 'python3' ;
207
+ platformService . setup ( p => p . isWindows ) . returns ( ( ) => testParams . isWindows ) ;
208
+ condaService . reset ( ) ;
209
+ condaService . setup ( c => c . getCondaEnvironment ( TypeMoq . It . isAny ( ) ) )
210
+ . returns ( ( ) => Promise . resolve ( {
211
+ name : testParams . envName ,
212
+ path : path . dirname ( pythonPath )
213
+ } ) ) ;
214
+ condaService . setup ( c => c . getCondaVersion ( ) )
215
+ . returns ( ( ) => Promise . resolve ( parse ( '4.4.0' , true ) ! ) ) ;
216
+ condaService . setup ( c => c . getCondaFileFromInterpreter ( TypeMoq . It . isAny ( ) , TypeMoq . It . isAny ( ) ) )
217
+ . returns ( ( ) => Promise . resolve ( interpreterPath ) ) ;
218
+
219
+ const provider = new CondaActivationCommandProvider ( condaService . object , platformService . object , configService . object ) ;
220
+ const activationCommands = await provider . getActivationCommands ( undefined , TerminalShellType . bash ) ;
221
+
222
+ expect ( activationCommands ) . to . deep . equal ( testParams . expectedResult , 'Incorrect Activation command' ) ;
223
+ } ) ;
224
+ } ) ;
225
+
173
226
async function expectNoCondaActivationCommandForPowershell ( isWindows : boolean , isOsx : boolean , isLinux : boolean , pythonPath : string , shellType : TerminalShellType , hasSpaceInEnvironmentName = false ) {
174
227
terminalSettings . setup ( t => t . activateEnvironment ) . returns ( ( ) => true ) ;
175
228
platformService . setup ( p => p . isLinux ) . returns ( ( ) => isLinux ) ;
0 commit comments