@@ -93,7 +93,8 @@ describe('WorkerChannel', () => {
93
93
environmentVariables : {
94
94
"hello" : "world" ,
95
95
"SystemDrive" : "Q:"
96
- }
96
+ } ,
97
+ functionAppDirectory : null
97
98
}
98
99
} ) ;
99
100
sinon . assert . calledWith ( stream . written , < rpc . IStreamingMessage > {
@@ -115,7 +116,8 @@ describe('WorkerChannel', () => {
115
116
stream . addTestMessage ( {
116
117
requestId : 'id' ,
117
118
functionEnvironmentReloadRequest : {
118
- environmentVariables : { }
119
+ environmentVariables : { } ,
120
+ functionAppDirectory : null
119
121
}
120
122
} ) ;
121
123
sinon . assert . calledWith ( stream . written , < rpc . IStreamingMessage > {
@@ -134,7 +136,8 @@ describe('WorkerChannel', () => {
134
136
stream . write ( {
135
137
requestId : 'id' ,
136
138
functionEnvironmentReloadRequest : {
137
- environmentVariables : { }
139
+ environmentVariables : { } ,
140
+ functionAppDirectory : null
138
141
}
139
142
} ) ;
140
143
} ) . to . not . throw ( ) ;
@@ -150,12 +153,66 @@ describe('WorkerChannel', () => {
150
153
stream . write ( {
151
154
requestId : 'id' ,
152
155
functionEnvironmentReloadRequest : {
153
- environmentVariables : null
156
+ environmentVariables : null ,
157
+ functionAppDirectory : null
154
158
}
155
159
} ) ;
156
160
} ) . to . not . throw ( ) ;
157
161
} ) ;
158
162
163
+ it ( 'reloads environment variable and keeps cwd without functionAppDirectory' , ( ) => {
164
+ let cwd = process . cwd ( ) ;
165
+ stream . addTestMessage ( {
166
+ requestId : 'id' ,
167
+ functionEnvironmentReloadRequest : {
168
+ environmentVariables : {
169
+ "hello" : "world" ,
170
+ "SystemDrive" : "Q:"
171
+ } ,
172
+ functionAppDirectory : null
173
+ }
174
+ } ) ;
175
+ sinon . assert . calledWith ( stream . written , < rpc . IStreamingMessage > {
176
+ requestId : 'id' ,
177
+ functionEnvironmentReloadResponse : {
178
+ result : {
179
+ status : rpc . StatusResult . Status . Success
180
+ }
181
+ }
182
+ } ) ;
183
+ expect ( process . env . hello ) . to . equal ( "world" ) ;
184
+ expect ( process . env . SystemDrive ) . to . equal ( "Q:" ) ;
185
+ expect ( process . cwd ( ) == cwd ) ;
186
+ } ) ;
187
+
188
+ it ( 'reloads environment variable and changes functionAppDirectory' , ( ) => {
189
+ let cwd = process . cwd ( ) ;
190
+ let newDir = "/" ;
191
+ stream . addTestMessage ( {
192
+ requestId : 'id' ,
193
+ functionEnvironmentReloadRequest : {
194
+ environmentVariables : {
195
+ "hello" : "world" ,
196
+ "SystemDrive" : "Q:"
197
+ } ,
198
+ functionAppDirectory : newDir
199
+ }
200
+ } ) ;
201
+ sinon . assert . calledWith ( stream . written , < rpc . IStreamingMessage > {
202
+ requestId : 'id' ,
203
+ functionEnvironmentReloadResponse : {
204
+ result : {
205
+ status : rpc . StatusResult . Status . Success
206
+ }
207
+ }
208
+ } ) ;
209
+ expect ( process . env . hello ) . to . equal ( "world" ) ;
210
+ expect ( process . env . SystemDrive ) . to . equal ( "Q:" ) ;
211
+ expect ( process . cwd ( ) != newDir ) ;
212
+ expect ( process . cwd ( ) == newDir ) ;
213
+ process . chdir ( cwd ) ;
214
+ } ) ;
215
+
159
216
it ( 'invokes function' , ( ) => {
160
217
loader . getFunc . returns ( ( context ) => context . done ( ) ) ;
161
218
loader . getInfo . returns ( {
0 commit comments