55
66import { expect } from 'chai' ;
77import * as path from 'path' ;
8+ import { parse } from 'semver' ;
89import * as TypeMoq from 'typemoq' ;
910import { Disposable } from 'vscode' ;
1011import '../../../client/common/extensions' ;
@@ -105,15 +106,19 @@ suite('Terminal Environment Activation conda', () => {
105106 test ( 'Conda activation on bash uses "source" before 4.4.0' , async ( ) => {
106107 const envName = 'EnvA' ;
107108 const pythonPath = 'python3' ;
109+ const condaPath = path . join ( 'a' , 'b' , 'c' , 'conda' ) ;
108110 platformService . setup ( p => p . isWindows ) . returns ( ( ) => false ) ;
111+ condaService . reset ( ) ;
109112 condaService . setup ( c => c . getCondaEnvironment ( TypeMoq . It . isAny ( ) ) )
110113 . returns ( ( ) => Promise . resolve ( {
111114 name : envName ,
112115 path : path . dirname ( pythonPath )
113116 } ) ) ;
117+ condaService . setup ( c => c . getCondaFile ( ) )
118+ . returns ( ( ) => Promise . resolve ( condaPath ) ) ;
114119 condaService . setup ( c => c . getCondaVersion ( ) )
115- . returns ( ( ) => Promise . resolve ( '4.3.1' ) ) ;
116- const expected = [ ' source activate EnvA' ] ;
120+ . returns ( ( ) => Promise . resolve ( parse ( '4.3.1' , true ) ! ) ) ;
121+ const expected = [ ` source ${ path . join ( path . dirname ( condaPath ) , ' activate' ) . fileToCommandArgument ( ) } EnvA` ] ;
117122
118123 const provider = new CondaActivationCommandProvider ( serviceContainer . object ) ;
119124 const activationCommands = await provider . getActivationCommands ( undefined , TerminalShellType . bash ) ;
@@ -124,15 +129,19 @@ suite('Terminal Environment Activation conda', () => {
124129 test ( 'Conda activation on bash uses "conda" after 4.4.0' , async ( ) => {
125130 const envName = 'EnvA' ;
126131 const pythonPath = 'python3' ;
132+ const condaPath = path . join ( 'a' , 'b' , 'c' , 'conda' ) ;
127133 platformService . setup ( p => p . isWindows ) . returns ( ( ) => false ) ;
134+ condaService . reset ( ) ;
128135 condaService . setup ( c => c . getCondaEnvironment ( TypeMoq . It . isAny ( ) ) )
129136 . returns ( ( ) => Promise . resolve ( {
130137 name : envName ,
131138 path : path . dirname ( pythonPath )
132139 } ) ) ;
140+ condaService . setup ( c => c . getCondaFile ( ) )
141+ . returns ( ( ) => Promise . resolve ( condaPath ) ) ;
133142 condaService . setup ( c => c . getCondaVersion ( ) )
134- . returns ( ( ) => Promise . resolve ( '4.4.0' ) ) ;
135- const expected = [ `${ conda } activate EnvA` ] ;
143+ . returns ( ( ) => Promise . resolve ( parse ( '4.4.0' , true ) ! ) ) ;
144+ const expected = [ `source ${ path . join ( path . dirname ( condaPath ) , ' activate' ) . fileToCommandArgument ( ) } EnvA` ] ;
136145
137146 const provider = new CondaActivationCommandProvider ( serviceContainer . object ) ;
138147 const activationCommands = await provider . getActivationCommands ( undefined , TerminalShellType . bash ) ;
0 commit comments