@@ -8,7 +8,11 @@ import * as sinon from 'sinon';
8
8
import { instance , mock , verify , when } from 'ts-mockito' ;
9
9
import * as TypeMoq from 'typemoq' ;
10
10
import { ConfigurationTarget , Uri , WorkspaceConfiguration } from 'vscode' ;
11
- import { IApplicationShell , IWorkspaceService } from '../../../client/common/application/types' ;
11
+ import {
12
+ IApplicationEnvironment ,
13
+ IApplicationShell ,
14
+ IWorkspaceService ,
15
+ } from '../../../client/common/application/types' ;
12
16
import { PersistentStateFactory } from '../../../client/common/persistentState' ;
13
17
import { IPlatformService } from '../../../client/common/platform/types' ;
14
18
import { IBrowserService , IPersistentState , IPersistentStateFactory } from '../../../client/common/types' ;
@@ -28,6 +32,7 @@ suite('Conda Inherit Env Prompt', async () => {
28
32
let interpreterService : TypeMoq . IMock < IInterpreterService > ;
29
33
let platformService : TypeMoq . IMock < IPlatformService > ;
30
34
let browserService : TypeMoq . IMock < IBrowserService > ;
35
+ let applicationEnvironment : TypeMoq . IMock < IApplicationEnvironment > ;
31
36
let persistentStateFactory : IPersistentStateFactory ;
32
37
let notificationPromptEnabled : TypeMoq . IMock < IPersistentState < any > > ;
33
38
let condaInheritEnvPrompt : CondaInheritEnvPrompt ;
@@ -45,13 +50,17 @@ suite('Conda Inherit Env Prompt', async () => {
45
50
interpreterService = TypeMoq . Mock . ofType < IInterpreterService > ( ) ;
46
51
persistentStateFactory = mock ( PersistentStateFactory ) ;
47
52
platformService = TypeMoq . Mock . ofType < IPlatformService > ( ) ;
53
+ applicationEnvironment = TypeMoq . Mock . ofType < IApplicationEnvironment > ( ) ;
54
+ applicationEnvironment . setup ( ( a ) => a . remoteName ) . returns ( ( ) => undefined ) ;
48
55
condaInheritEnvPrompt = new CondaInheritEnvPrompt (
49
56
interpreterService . object ,
50
57
workspaceService . object ,
51
58
browserService . object ,
52
59
appShell . object ,
53
60
instance ( persistentStateFactory ) ,
61
+
54
62
platformService . object ,
63
+ applicationEnvironment . object ,
55
64
) ;
56
65
} ) ;
57
66
test ( 'Returns false if prompt has already been shown in the current session' , async ( ) => {
@@ -61,7 +70,9 @@ suite('Conda Inherit Env Prompt', async () => {
61
70
browserService . object ,
62
71
appShell . object ,
63
72
instance ( persistentStateFactory ) ,
73
+
64
74
platformService . object ,
75
+ applicationEnvironment . object ,
65
76
true ,
66
77
) ;
67
78
const workspaceConfig = TypeMoq . Mock . ofType < WorkspaceConfiguration > ( ) ;
@@ -78,6 +89,14 @@ suite('Conda Inherit Env Prompt', async () => {
78
89
expect ( condaInheritEnvPrompt . hasPromptBeenShownInCurrentSession ) . to . equal ( true , 'Should be true' ) ;
79
90
verifyAll ( ) ;
80
91
} ) ;
92
+ test ( 'Returns false if running on remote' , async ( ) => {
93
+ applicationEnvironment . reset ( ) ;
94
+ applicationEnvironment . setup ( ( a ) => a . remoteName ) . returns ( ( ) => 'ssh' ) ;
95
+ const result = await condaInheritEnvPrompt . shouldShowPrompt ( resource ) ;
96
+ expect ( result ) . to . equal ( false , 'Prompt should not be shown' ) ;
97
+ expect ( condaInheritEnvPrompt . hasPromptBeenShownInCurrentSession ) . to . equal ( false , 'Should be false' ) ;
98
+ verifyAll ( ) ;
99
+ } ) ;
81
100
test ( 'Returns false if on Windows' , async ( ) => {
82
101
platformService
83
102
. setup ( ( ps ) => ps . isWindows )
@@ -245,6 +264,8 @@ suite('Conda Inherit Env Prompt', async () => {
245
264
interpreterService = TypeMoq . Mock . ofType < IInterpreterService > ( ) ;
246
265
persistentStateFactory = mock ( PersistentStateFactory ) ;
247
266
platformService = TypeMoq . Mock . ofType < IPlatformService > ( ) ;
267
+ applicationEnvironment = TypeMoq . Mock . ofType < IApplicationEnvironment > ( ) ;
268
+ applicationEnvironment . setup ( ( a ) => a . remoteName ) . returns ( ( ) => undefined ) ;
248
269
} ) ;
249
270
250
271
teardown ( ( ) => {
@@ -261,7 +282,9 @@ suite('Conda Inherit Env Prompt', async () => {
261
282
browserService . object ,
262
283
appShell . object ,
263
284
instance ( persistentStateFactory ) ,
285
+
264
286
platformService . object ,
287
+ applicationEnvironment . object ,
265
288
) ;
266
289
267
290
const promise = condaInheritEnvPrompt . activate ( resource ) ;
@@ -285,7 +308,9 @@ suite('Conda Inherit Env Prompt', async () => {
285
308
browserService . object ,
286
309
appShell . object ,
287
310
instance ( persistentStateFactory ) ,
311
+
288
312
platformService . object ,
313
+ applicationEnvironment . object ,
289
314
) ;
290
315
await condaInheritEnvPrompt . activate ( resource ) ;
291
316
assert . ok ( initializeInBackground . calledOnce ) ;
@@ -302,6 +327,8 @@ suite('Conda Inherit Env Prompt', async () => {
302
327
interpreterService = TypeMoq . Mock . ofType < IInterpreterService > ( ) ;
303
328
persistentStateFactory = mock ( PersistentStateFactory ) ;
304
329
platformService = TypeMoq . Mock . ofType < IPlatformService > ( ) ;
330
+ applicationEnvironment = TypeMoq . Mock . ofType < IApplicationEnvironment > ( ) ;
331
+ applicationEnvironment . setup ( ( a ) => a . remoteName ) . returns ( ( ) => undefined ) ;
305
332
} ) ;
306
333
307
334
teardown ( ( ) => {
@@ -319,7 +346,9 @@ suite('Conda Inherit Env Prompt', async () => {
319
346
browserService . object ,
320
347
appShell . object ,
321
348
instance ( persistentStateFactory ) ,
349
+
322
350
platformService . object ,
351
+ applicationEnvironment . object ,
323
352
) ;
324
353
await condaInheritEnvPrompt . initializeInBackground ( resource ) ;
325
354
assert . ok ( shouldShowPrompt . calledOnce ) ;
@@ -337,7 +366,9 @@ suite('Conda Inherit Env Prompt', async () => {
337
366
browserService . object ,
338
367
appShell . object ,
339
368
instance ( persistentStateFactory ) ,
369
+
340
370
platformService . object ,
371
+ applicationEnvironment . object ,
341
372
) ;
342
373
await condaInheritEnvPrompt . initializeInBackground ( resource ) ;
343
374
assert . ok ( shouldShowPrompt . calledOnce ) ;
@@ -355,6 +386,8 @@ suite('Conda Inherit Env Prompt', async () => {
355
386
browserService = TypeMoq . Mock . ofType < IBrowserService > ( ) ;
356
387
notificationPromptEnabled = TypeMoq . Mock . ofType < IPersistentState < any > > ( ) ;
357
388
platformService = TypeMoq . Mock . ofType < IPlatformService > ( ) ;
389
+ applicationEnvironment = TypeMoq . Mock . ofType < IApplicationEnvironment > ( ) ;
390
+ applicationEnvironment . setup ( ( a ) => a . remoteName ) . returns ( ( ) => undefined ) ;
358
391
when ( persistentStateFactory . createGlobalPersistentState ( condaInheritEnvPromptKey , true ) ) . thenReturn (
359
392
notificationPromptEnabled . object ,
360
393
) ;
@@ -364,7 +397,9 @@ suite('Conda Inherit Env Prompt', async () => {
364
397
browserService . object ,
365
398
appShell . object ,
366
399
instance ( persistentStateFactory ) ,
400
+
367
401
platformService . object ,
402
+ applicationEnvironment . object ,
368
403
) ;
369
404
} ) ;
370
405
0 commit comments