@@ -10,9 +10,9 @@ import { Uri, WorkspaceFolder } from 'vscode';
1010import  {  IWorkspaceService  }  from  '../../client/common/application/types' ; 
1111import  {  PlatformService  }  from  '../../client/common/platform/platformService' ; 
1212import  {  IConfigurationService ,  ICurrentProcess ,  IPythonSettings  }  from  '../../client/common/types' ; 
13- import  {  EnvironmentVariables  }  from  '../../client/common/variables/types' ; 
1413import  {  GlobalVirtualEnvironmentsSearchPathProvider  }  from  '../../client/interpreter/locators/services/globalVirtualEnvService' ; 
1514import  {  WorkspaceVirtualEnvironmentsSearchPathProvider  }  from  '../../client/interpreter/locators/services/workspaceVirtualEnvService' ; 
15+ import  {  IVirtualEnvironmentManager  }  from  '../../client/interpreter/virtualEnvs/types' ; 
1616import  {  ServiceContainer  }  from  '../../client/ioc/container' ; 
1717import  {  ServiceManager  }  from  '../../client/ioc/serviceManager' ; 
1818
@@ -23,6 +23,7 @@ suite('Virtual environments', () => {
2323 let  config : TypeMoq . IMock < IConfigurationService > ; 
2424 let  workspace : TypeMoq . IMock < IWorkspaceService > ; 
2525 let  process : TypeMoq . IMock < ICurrentProcess > ; 
26+  let  virtualEnvMgr : TypeMoq . IMock < IVirtualEnvironmentManager > ; 
2627
2728 setup ( ( )  =>  { 
2829 const  cont  =  new  Container ( ) ; 
@@ -33,39 +34,36 @@ suite('Virtual environments', () => {
3334 config  =  TypeMoq . Mock . ofType < IConfigurationService > ( ) ; 
3435 workspace  =  TypeMoq . Mock . ofType < IWorkspaceService > ( ) ; 
3536 process  =  TypeMoq . Mock . ofType < ICurrentProcess > ( ) ; 
37+  virtualEnvMgr  =  TypeMoq . Mock . ofType < IVirtualEnvironmentManager > ( ) ; 
3638
3739 config . setup ( x  =>  x . getSettings ( TypeMoq . It . isAny ( ) ) ) . returns ( ( )  =>  settings . object ) ; 
3840
3941 serviceManager . addSingletonInstance < IConfigurationService > ( IConfigurationService ,  config . object ) ; 
4042 serviceManager . addSingletonInstance < IWorkspaceService > ( IWorkspaceService ,  workspace . object ) ; 
4143 serviceManager . addSingletonInstance < ICurrentProcess > ( ICurrentProcess ,  process . object ) ; 
44+  serviceManager . addSingletonInstance < IVirtualEnvironmentManager > ( IVirtualEnvironmentManager ,  virtualEnvMgr . object ) ; 
4245 } ) ; 
4346
4447 test ( 'Global search paths' ,  async  ( )  =>  { 
4548 const  pathProvider  =  new  GlobalVirtualEnvironmentsSearchPathProvider ( serviceContainer ) ; 
4649
4750 const  homedir  =  os . homedir ( ) ; 
48-  const  folders  =  [ 'Envs' ,  '.virtualenvs' ,   '.pyenv' ] ; 
51+  const  folders  =  [ 'Envs' ,  '.virtualenvs' ] ; 
4952 settings . setup ( x  =>  x . venvFolders ) . returns ( ( )  =>  folders ) ; 
50- 
51-  let  paths  =  pathProvider . getSearchPaths ( ) ; 
53+   virtualEnvMgr . setup ( v   =>   v . getPyEnvRoot ( TypeMoq . It . isAny ( ) ) ) . returns ( ( )   =>   Promise . resolve ( undefined ) ) ; 
54+  let  paths  =  await   pathProvider . getSearchPaths ( ) ; 
5255 let  expected  =  folders . map ( item  =>  path . join ( homedir ,  item ) ) ; 
53-  expected . push ( path . join ( homedir ,  '.pyenv' ,  'versions' ) ) ; 
5456
57+  virtualEnvMgr . verifyAll ( ) ; 
5558 expect ( paths ) . to . deep . equal ( expected ,  'Global search folder list is incorrect.' ) ; 
5659
57-  const  envMap : EnvironmentVariables  =  { } ; 
58-  process . setup ( x  =>  x . env ) . returns ( ( )  =>  envMap ) ; 
59- 
60-  const  customFolder  =  path . join ( homedir ,  'some_folder' ) ; 
61-  // tslint:disable-next-line:no-string-literal 
62-  envMap [ 'PYENV_ROOT' ]  =  customFolder ; 
63-  paths  =  pathProvider . getSearchPaths ( ) ; 
60+  virtualEnvMgr . reset ( ) ; 
61+  virtualEnvMgr . setup ( v  =>  v . getPyEnvRoot ( TypeMoq . It . isAny ( ) ) ) . returns ( ( )  =>  Promise . resolve ( 'pyenv_path' ) ) ; 
62+  paths  =  await  pathProvider . getSearchPaths ( ) ; 
6463
65-  expected  =  folders . map ( item  =>  path . join ( homedir ,  item ) ) ; 
66-  expected . push ( customFolder ) ; 
67-  expected . push ( path . join ( customFolder ,  'versions' ) ) ; 
68-  expect ( paths ) . to . deep . equal ( expected ,  'PYENV_ROOT not resolved correctly.' ) ; 
64+  virtualEnvMgr . verifyAll ( ) ; 
65+  expected  =  expected . concat ( [ 'pyenv_path' ,  path . join ( 'pyenv_path' ,  'versions' ) ] ) ; 
66+  expect ( paths ) . to . deep . equal ( expected ,  'pyenv path not resolved correctly.' ) ; 
6967 } ) ; 
7068
7169 test ( 'Workspace search paths' ,  async  ( )  =>  { 
@@ -81,7 +79,7 @@ suite('Virtual environments', () => {
8179 workspace . setup ( x  =>  x . workspaceFolders ) . returns ( ( )  =>  [ wsRoot . object ,  folder1 . object ] ) ; 
8280
8381 const  pathProvider  =  new  WorkspaceVirtualEnvironmentsSearchPathProvider ( serviceContainer ) ; 
84-  const  paths  =  pathProvider . getSearchPaths ( Uri . file ( '' ) ) ; 
82+  const  paths  =  await   pathProvider . getSearchPaths ( Uri . file ( '' ) ) ; 
8583
8684 const  homedir  =  os . homedir ( ) ; 
8785 const  isWindows  =  new  PlatformService ( ) ; 
0 commit comments