@@ -10,6 +10,7 @@ import * as TypeMoq from 'typemoq';
1010import { ConfigurationTarget , Uri , WorkspaceConfiguration } from 'vscode' ;
1111import { IApplicationShell , IWorkspaceService } from '../../../client/common/application/types' ;
1212import { PersistentStateFactory } from '../../../client/common/persistentState' ;
13+ import { IPlatformService } from '../../../client/common/platform/types' ;
1314import { IBrowserService , IPersistentState , IPersistentStateFactory } from '../../../client/common/types' ;
1415import { createDeferred , createDeferredFromPromise , sleep } from '../../../client/common/utils/async' ;
1516import { Common , InteractiveShiftEnterBanner , Interpreters } from '../../../client/common/utils/localize' ;
@@ -24,6 +25,7 @@ suite('Conda Inherit Env Prompt', async () => {
2425 let workspaceService : TypeMoq . IMock < IWorkspaceService > ;
2526 let appShell : TypeMoq . IMock < IApplicationShell > ;
2627 let interpreterService : TypeMoq . IMock < IInterpreterService > ;
28+ let platformService : TypeMoq . IMock < IPlatformService > ;
2729 let browserService : TypeMoq . IMock < IBrowserService > ;
2830 let persistentStateFactory : IPersistentStateFactory ;
2931 let notificationPromptEnabled : TypeMoq . IMock < IPersistentState < any > > ;
@@ -41,10 +43,26 @@ suite('Conda Inherit Env Prompt', async () => {
4143 browserService = TypeMoq . Mock . ofType < IBrowserService > ( ) ;
4244 interpreterService = TypeMoq . Mock . ofType < IInterpreterService > ( ) ;
4345 persistentStateFactory = mock ( PersistentStateFactory ) ;
44- condaInheritEnvPrompt = new CondaInheritEnvPrompt ( interpreterService . object , workspaceService . object , browserService . object , appShell . object , instance ( persistentStateFactory ) ) ;
46+ platformService = TypeMoq . Mock . ofType < IPlatformService > ( ) ;
47+ condaInheritEnvPrompt = new CondaInheritEnvPrompt (
48+ interpreterService . object ,
49+ workspaceService . object ,
50+ browserService . object ,
51+ appShell . object ,
52+ instance ( persistentStateFactory ) ,
53+ platformService . object
54+ ) ;
4555 } ) ;
4656 test ( 'Returns false if prompt has already been shown in the current session' , async ( ) => {
47- condaInheritEnvPrompt = new CondaInheritEnvPrompt ( interpreterService . object , workspaceService . object , browserService . object , appShell . object , instance ( persistentStateFactory ) , true ) ;
57+ condaInheritEnvPrompt = new CondaInheritEnvPrompt (
58+ interpreterService . object ,
59+ workspaceService . object ,
60+ browserService . object ,
61+ appShell . object ,
62+ instance ( persistentStateFactory ) ,
63+ platformService . object ,
64+ true
65+ ) ;
4866 const workspaceConfig = TypeMoq . Mock . ofType < WorkspaceConfiguration > ( ) ;
4967 interpreterService
5068 . setup ( is => is . getActiveInterpreter ( resource ) )
@@ -59,11 +77,25 @@ suite('Conda Inherit Env Prompt', async () => {
5977 expect ( condaInheritEnvPrompt . hasPromptBeenShownInCurrentSession ) . to . equal ( true , 'Should be true' ) ;
6078 verifyAll ( ) ;
6179 } ) ;
80+ test ( 'Returns false if on Windows' , async ( ) => {
81+ platformService
82+ . setup ( ps => ps . isWindows )
83+ . returns ( ( ) => true )
84+ . verifiable ( TypeMoq . Times . once ( ) ) ;
85+ const result = await condaInheritEnvPrompt . shouldShowPrompt ( resource ) ;
86+ expect ( result ) . to . equal ( false , 'Prompt should not be shown' ) ;
87+ expect ( condaInheritEnvPrompt . hasPromptBeenShownInCurrentSession ) . to . equal ( false , 'Should be false' ) ;
88+ verifyAll ( ) ;
89+ } ) ;
6290 test ( 'Returns false if active interpreter is not of type Conda' , async ( ) => {
6391 const interpreter = {
6492 type : InterpreterType . Pipenv
6593 } ;
6694 const workspaceConfig = TypeMoq . Mock . ofType < WorkspaceConfiguration > ( ) ;
95+ platformService
96+ . setup ( ps => ps . isWindows )
97+ . returns ( ( ) => false )
98+ . verifiable ( TypeMoq . Times . once ( ) ) ;
6799 interpreterService
68100 . setup ( is => is . getActiveInterpreter ( resource ) )
69101 . returns ( ( ) => Promise . resolve ( interpreter ) as any )
@@ -79,6 +111,10 @@ suite('Conda Inherit Env Prompt', async () => {
79111 } ) ;
80112 test ( 'Returns false if no active interpreter is present' , async ( ) => {
81113 const workspaceConfig = TypeMoq . Mock . ofType < WorkspaceConfiguration > ( ) ;
114+ platformService
115+ . setup ( ps => ps . isWindows )
116+ . returns ( ( ) => false )
117+ . verifiable ( TypeMoq . Times . once ( ) ) ;
82118 interpreterService
83119 . setup ( is => is . getActiveInterpreter ( resource ) )
84120 . returns ( ( ) => Promise . resolve ( undefined ) )
@@ -97,6 +133,10 @@ suite('Conda Inherit Env Prompt', async () => {
97133 type : InterpreterType . Conda
98134 } ;
99135 const workspaceConfig = TypeMoq . Mock . ofType < WorkspaceConfiguration > ( ) ;
136+ platformService
137+ . setup ( ps => ps . isWindows )
138+ . returns ( ( ) => false )
139+ . verifiable ( TypeMoq . Times . once ( ) ) ;
100140 interpreterService
101141 . setup ( is => is . getActiveInterpreter ( resource ) )
102142 . returns ( ( ) => Promise . resolve ( interpreter ) as any )
@@ -107,7 +147,8 @@ suite('Conda Inherit Env Prompt', async () => {
107147 . verifiable ( TypeMoq . Times . once ( ) ) ;
108148 workspaceConfig
109149 . setup ( ws => ws . inspect < boolean > ( 'integrated.inheritEnv' ) )
110- . returns ( ( ) => undefined ) ;
150+ . returns ( ( ) => undefined )
151+ . verifiable ( TypeMoq . Times . once ( ) ) ;
111152 const result = await condaInheritEnvPrompt . shouldShowPrompt ( resource ) ;
112153 expect ( result ) . to . equal ( false , 'Prompt should not be shown' ) ;
113154 expect ( condaInheritEnvPrompt . hasPromptBeenShownInCurrentSession ) . to . equal ( false , 'Should be false' ) ;
@@ -144,6 +185,10 @@ suite('Conda Inherit Env Prompt', async () => {
144185 type : InterpreterType . Conda
145186 } ;
146187 const workspaceConfig = TypeMoq . Mock . ofType < WorkspaceConfiguration > ( ) ;
188+ platformService
189+ . setup ( ps => ps . isWindows )
190+ . returns ( ( ) => false )
191+ . verifiable ( TypeMoq . Times . once ( ) ) ;
147192 interpreterService
148193 . setup ( is => is . getActiveInterpreter ( resource ) )
149194 . returns ( ( ) => Promise . resolve ( interpreter ) as any )
@@ -171,6 +216,10 @@ suite('Conda Inherit Env Prompt', async () => {
171216 workspaceFolderValue : undefined
172217 } ;
173218 const workspaceConfig = TypeMoq . Mock . ofType < WorkspaceConfiguration > ( ) ;
219+ platformService
220+ . setup ( ps => ps . isWindows )
221+ . returns ( ( ) => false )
222+ . verifiable ( TypeMoq . Times . once ( ) ) ;
174223 interpreterService
175224 . setup ( is => is . getActiveInterpreter ( resource ) )
176225 . returns ( ( ) => Promise . resolve ( interpreter ) as any )
@@ -196,6 +245,7 @@ suite('Conda Inherit Env Prompt', async () => {
196245 browserService = TypeMoq . Mock . ofType < IBrowserService > ( ) ;
197246 interpreterService = TypeMoq . Mock . ofType < IInterpreterService > ( ) ;
198247 persistentStateFactory = mock ( PersistentStateFactory ) ;
248+ platformService = TypeMoq . Mock . ofType < IPlatformService > ( ) ;
199249 } ) ;
200250
201251 teardown ( ( ) => {
@@ -206,7 +256,14 @@ suite('Conda Inherit Env Prompt', async () => {
206256 const initializeInBackgroundDeferred = createDeferred < void > ( ) ;
207257 initializeInBackground = sinon . stub ( CondaInheritEnvPrompt . prototype , 'initializeInBackground' ) ;
208258 initializeInBackground . callsFake ( ( ) => initializeInBackgroundDeferred . promise ) ;
209- condaInheritEnvPrompt = new CondaInheritEnvPrompt ( interpreterService . object , workspaceService . object , browserService . object , appShell . object , instance ( persistentStateFactory ) ) ;
259+ condaInheritEnvPrompt = new CondaInheritEnvPrompt (
260+ interpreterService . object ,
261+ workspaceService . object ,
262+ browserService . object ,
263+ appShell . object ,
264+ instance ( persistentStateFactory ) ,
265+ platformService . object
266+ ) ;
210267
211268 const promise = condaInheritEnvPrompt . activate ( resource ) ;
212269 const deferred = createDeferredFromPromise ( promise ) ;
@@ -223,7 +280,14 @@ suite('Conda Inherit Env Prompt', async () => {
223280 test ( 'Ignores errors raised by initializeInBackground()' , async ( ) => {
224281 initializeInBackground = sinon . stub ( CondaInheritEnvPrompt . prototype , 'initializeInBackground' ) ;
225282 initializeInBackground . rejects ( new Error ( 'Kaboom' ) ) ;
226- condaInheritEnvPrompt = new CondaInheritEnvPrompt ( interpreterService . object , workspaceService . object , browserService . object , appShell . object , instance ( persistentStateFactory ) ) ;
283+ condaInheritEnvPrompt = new CondaInheritEnvPrompt (
284+ interpreterService . object ,
285+ workspaceService . object ,
286+ browserService . object ,
287+ appShell . object ,
288+ instance ( persistentStateFactory ) ,
289+ platformService . object
290+ ) ;
227291 await condaInheritEnvPrompt . activate ( resource ) ;
228292 assert . ok ( initializeInBackground . calledOnce ) ;
229293 } ) ;
@@ -238,6 +302,7 @@ suite('Conda Inherit Env Prompt', async () => {
238302 browserService = TypeMoq . Mock . ofType < IBrowserService > ( ) ;
239303 interpreterService = TypeMoq . Mock . ofType < IInterpreterService > ( ) ;
240304 persistentStateFactory = mock ( PersistentStateFactory ) ;
305+ platformService = TypeMoq . Mock . ofType < IPlatformService > ( ) ;
241306 } ) ;
242307
243308 teardown ( ( ) => {
@@ -249,7 +314,14 @@ suite('Conda Inherit Env Prompt', async () => {
249314 shouldShowPrompt . callsFake ( ( ) => Promise . resolve ( true ) ) ;
250315 promptAndUpdate = sinon . stub ( CondaInheritEnvPrompt . prototype , 'promptAndUpdate' ) ;
251316 promptAndUpdate . callsFake ( ( ) => Promise . resolve ( undefined ) ) ;
252- condaInheritEnvPrompt = new CondaInheritEnvPrompt ( interpreterService . object , workspaceService . object , browserService . object , appShell . object , instance ( persistentStateFactory ) ) ;
317+ condaInheritEnvPrompt = new CondaInheritEnvPrompt (
318+ interpreterService . object ,
319+ workspaceService . object ,
320+ browserService . object ,
321+ appShell . object ,
322+ instance ( persistentStateFactory ) ,
323+ platformService . object
324+ ) ;
253325 await condaInheritEnvPrompt . initializeInBackground ( resource ) ;
254326 assert . ok ( shouldShowPrompt . calledOnce ) ;
255327 assert . ok ( promptAndUpdate . calledOnce ) ;
@@ -260,7 +332,14 @@ suite('Conda Inherit Env Prompt', async () => {
260332 shouldShowPrompt . callsFake ( ( ) => Promise . resolve ( false ) ) ;
261333 promptAndUpdate = sinon . stub ( CondaInheritEnvPrompt . prototype , 'promptAndUpdate' ) ;
262334 promptAndUpdate . callsFake ( ( ) => Promise . resolve ( undefined ) ) ;
263- condaInheritEnvPrompt = new CondaInheritEnvPrompt ( interpreterService . object , workspaceService . object , browserService . object , appShell . object , instance ( persistentStateFactory ) ) ;
335+ condaInheritEnvPrompt = new CondaInheritEnvPrompt (
336+ interpreterService . object ,
337+ workspaceService . object ,
338+ browserService . object ,
339+ appShell . object ,
340+ instance ( persistentStateFactory ) ,
341+ platformService . object
342+ ) ;
264343 await condaInheritEnvPrompt . initializeInBackground ( resource ) ;
265344 assert . ok ( shouldShowPrompt . calledOnce ) ;
266345 assert . ok ( promptAndUpdate . notCalled ) ;
@@ -276,8 +355,16 @@ suite('Conda Inherit Env Prompt', async () => {
276355 persistentStateFactory = mock ( PersistentStateFactory ) ;
277356 browserService = TypeMoq . Mock . ofType < IBrowserService > ( ) ;
278357 notificationPromptEnabled = TypeMoq . Mock . ofType < IPersistentState < any > > ( ) ;
358+ platformService = TypeMoq . Mock . ofType < IPlatformService > ( ) ;
279359 when ( persistentStateFactory . createGlobalPersistentState ( condaInheritEnvPromptKey , true ) ) . thenReturn ( notificationPromptEnabled . object ) ;
280- condaInheritEnvPrompt = new CondaInheritEnvPrompt ( interpreterService . object , workspaceService . object , browserService . object , appShell . object , instance ( persistentStateFactory ) ) ;
360+ condaInheritEnvPrompt = new CondaInheritEnvPrompt (
361+ interpreterService . object ,
362+ workspaceService . object ,
363+ browserService . object ,
364+ appShell . object ,
365+ instance ( persistentStateFactory ) ,
366+ platformService . object
367+ ) ;
281368 } ) ;
282369
283370 test ( 'Does not display prompt if it is disabled' , async ( ) => {
0 commit comments