@@ -514,4 +514,33 @@ suite('Interpreters Conda Service', () => {
514
514
assert . equal ( isAvailable , false ) ;
515
515
} ) ;
516
516
517
+ async function testFailureOfGettingCondaEnvironments ( isWindows : boolean , isOsx : boolean , isLinux : boolean , pythonPath : string ) {
518
+ platformService . setup ( p => p . isLinux ) . returns ( ( ) => isLinux ) ;
519
+ platformService . setup ( p => p . isWindows ) . returns ( ( ) => isWindows ) ;
520
+ platformService . setup ( p => p . isMac ) . returns ( ( ) => isOsx ) ;
521
+
522
+ const stateFactory = TypeMoq . Mock . ofType < IPersistentStateFactory > ( ) ;
523
+ serviceContainer . setup ( c => c . get ( TypeMoq . It . isValue ( IPersistentStateFactory ) ) ) . returns ( ( ) => stateFactory . object ) ;
524
+ const state = new MockState ( { data : undefined } ) ;
525
+ stateFactory . setup ( s => s . createGlobalPersistentState ( TypeMoq . It . isValue ( 'CONDA_ENVIRONMENTS' ) , TypeMoq . It . isValue ( undefined ) ) ) . returns ( ( ) => state ) ;
526
+ processService . setup ( p => p . exec ( TypeMoq . It . isValue ( 'conda' ) , TypeMoq . It . isValue ( [ '--version' ] ) , TypeMoq . It . isAny ( ) ) ) . returns ( ( ) => Promise . resolve ( { stdout : 'some value' } ) ) ;
527
+ processService . setup ( p => p . exec ( TypeMoq . It . isValue ( 'conda' ) , TypeMoq . It . isValue ( [ 'env' , 'list' ] ) , TypeMoq . It . isAny ( ) ) ) . returns ( ( ) => Promise . reject ( new Error ( 'Failed' ) ) ) ;
528
+ const condaEnv = await condaService . getCondaEnvironment ( pythonPath ) ;
529
+ expect ( condaEnv ) . to . be . equal ( undefined , 'Conda should be undefined' ) ;
530
+ }
531
+ test ( 'Fails to identify an environment as a conda env (windows)' , async ( ) => {
532
+ const pythonPath = path . join ( 'c' , 'users' , 'xyz' , '.conda' , 'envs' , 'one' , 'python.exe' ) ;
533
+ fileSystem . setup ( f => f . directoryExistsAsync ( TypeMoq . It . isValue ( path . join ( path . dirname ( pythonPath ) , 'conda-meta' ) ) ) ) . returns ( ( ) => Promise . resolve ( true ) ) ;
534
+ await testFailureOfGettingCondaEnvironments ( true , false , false , pythonPath ) ;
535
+ } ) ;
536
+ test ( 'Fails to identify an environment as a conda env (linux)' , async ( ) => {
537
+ const pythonPath = path . join ( 'c' , 'users' , 'xyz' , '.conda' , 'envs' , 'one' , 'python' ) ;
538
+ fileSystem . setup ( f => f . directoryExistsAsync ( TypeMoq . It . isValue ( path . join ( path . dirname ( pythonPath ) , 'conda-meta' ) ) ) ) . returns ( ( ) => Promise . resolve ( true ) ) ;
539
+ await testFailureOfGettingCondaEnvironments ( false , false , true , pythonPath ) ;
540
+ } ) ;
541
+ test ( 'Fails to identify an environment as a conda env (osx)' , async ( ) => {
542
+ const pythonPath = path . join ( 'c' , 'users' , 'xyz' , '.conda' , 'envs' , 'one' , 'python' ) ;
543
+ fileSystem . setup ( f => f . directoryExistsAsync ( TypeMoq . It . isValue ( path . join ( path . dirname ( pythonPath ) , 'conda-meta' ) ) ) ) . returns ( ( ) => Promise . resolve ( true ) ) ;
544
+ await testFailureOfGettingCondaEnvironments ( false , true , false , pythonPath ) ;
545
+ } ) ;
517
546
} ) ;
0 commit comments