@@ -32,45 +32,92 @@ describe(__filename, () => {
3232 assert . deepEqual ( task . problemMatchers , [ "$bricks-sync" ] ) ;
3333 } ) ;
3434
35- it ( "should create pseudo terminal with correct environment variables" , ( ) => {
36- const mockDbWorkspace = mock ( DatabricksWorkspace ) ;
37- when ( mockDbWorkspace . authProvider ) . thenReturn (
38- new ProfileAuthProvider (
39- new URL ( "https://000000000000.00.azuredatabricks.net/" ) ,
40- "profile"
41- )
42- ) ;
35+ describe ( "pseudo terminal" , ( ) => {
36+ let env : NodeJS . ProcessEnv ;
4337
44- const mockSyncDestination = mock ( SyncDestination ) ;
45- when ( mockSyncDestination . vscodeWorkspacePath ) . thenReturn (
46- Uri . file ( "/path/to/local/workspace" )
47- ) ;
38+ beforeEach ( ( ) => {
39+ // Save environment.
40+ env = process . env ;
4841
49- when ( connection . databricksWorkspace ) . thenReturn (
50- instance ( mockDbWorkspace )
51- ) ;
52- when ( connection . syncDestination ) . thenReturn (
53- instance ( mockSyncDestination )
54- ) ;
42+ // Create copy so it is safe to mutate it in tests.
43+ process . env = {
44+ ...env ,
45+ } ;
46+ } ) ;
5547
56- const terminal = new LazyCustomSyncTerminal (
57- instance ( connection ) ,
58- instance ( cli ) ,
59- "full" ,
60- ( ) => { }
61- ) ;
48+ afterEach ( ( ) => {
49+ // Restore original environment.
50+ process . env = env ;
51+ } ) ;
52+
53+ let terminal : LazyCustomSyncTerminal ;
54+
55+ beforeEach ( ( ) => {
56+ const mockDbWorkspace = mock ( DatabricksWorkspace ) ;
57+ when ( mockDbWorkspace . authProvider ) . thenReturn (
58+ new ProfileAuthProvider (
59+ new URL ( "https://000000000000.00.azuredatabricks.net/" ) ,
60+ "profile"
61+ )
62+ ) ;
63+
64+ const mockSyncDestination = mock ( SyncDestination ) ;
65+ when ( mockSyncDestination . vscodeWorkspacePath ) . thenReturn (
66+ Uri . file ( "/path/to/local/workspace" )
67+ ) ;
68+
69+ when ( connection . databricksWorkspace ) . thenReturn (
70+ instance ( mockDbWorkspace )
71+ ) ;
72+
73+ when ( connection . syncDestination ) . thenReturn (
74+ instance ( mockSyncDestination )
75+ ) ;
76+
77+ terminal = new LazyCustomSyncTerminal (
78+ instance ( connection ) ,
79+ instance ( cli ) ,
80+ "full" ,
81+ ( ) => { }
82+ ) ;
83+ } ) ;
84+
85+ it ( "should receive correct environment variables" , ( ) => {
86+ delete process . env [ "HTTP_PROXY" ] ;
87+ delete process . env [ "HTTPS_PROXY" ] ;
88+
89+ assert . deepEqual ( terminal . getProcessOptions ( ) , {
90+ cwd : Uri . file ( "/path/to/local/workspace" ) . fsPath ,
91+ env : {
92+ /* eslint-disable @typescript-eslint/naming-convention */
93+ BRICKS_ROOT : Uri . file ( "/path/to/local/workspace" ) . fsPath ,
94+ DATABRICKS_CONFIG_PROFILE : "profile" ,
95+ DATABRICKS_CONFIG_FILE : undefined ,
96+ HOME : process . env . HOME ,
97+ PATH : process . env . PATH ,
98+ /* eslint-enable @typescript-eslint/naming-convention */
99+ } ,
100+ } ) ;
101+ } ) ;
102+
103+ it ( "should pass through proxy variables if set" , ( ) => {
104+ process . env . HTTP_PROXY = "http_proxy" ;
105+ process . env . HTTPS_PROXY = "https_proxy" ;
62106
63- assert . deepEqual ( terminal . getProcessOptions ( ) , {
64- cwd : Uri . file ( "/path/to/local/workspace" ) . fsPath ,
65- env : {
66- /* eslint-disable @typescript-eslint/naming-convention */
67- BRICKS_ROOT : Uri . file ( "/path/to/local/workspace" ) . fsPath ,
68- DATABRICKS_CONFIG_PROFILE : "profile" ,
69- DATABRICKS_CONFIG_FILE : undefined ,
70- HOME : process . env . HOME ,
71- PATH : process . env . PATH ,
72- /* eslint-enable @typescript-eslint/naming-convention */
73- } ,
107+ assert . deepEqual ( terminal . getProcessOptions ( ) , {
108+ cwd : Uri . file ( "/path/to/local/workspace" ) . fsPath ,
109+ env : {
110+ /* eslint-disable @typescript-eslint/naming-convention */
111+ BRICKS_ROOT : Uri . file ( "/path/to/local/workspace" ) . fsPath ,
112+ DATABRICKS_CONFIG_PROFILE : "profile" ,
113+ DATABRICKS_CONFIG_FILE : undefined ,
114+ HOME : process . env . HOME ,
115+ PATH : process . env . PATH ,
116+ HTTP_PROXY : "http_proxy" ,
117+ HTTPS_PROXY : "https_proxy" ,
118+ /* eslint-enable @typescript-eslint/naming-convention */
119+ } ,
120+ } ) ;
74121 } ) ;
75122 } ) ;
76123} ) ;
0 commit comments