@@ -359,6 +359,41 @@ public async Task HttpTrigger_CustomRoute_Post_ReturnsExpectedResponse()
359
359
Assert . Equal ( ( string ) product [ "name" ] , ( string ) resultProduct [ "name" ] ) ;
360
360
}
361
361
362
+ [ Fact ]
363
+ public async Task SharedDirectory_Node_ReloadsOnFileChange ( )
364
+ {
365
+ string uri = "api/httptrigger?code=hyexydhln844f2mb7hgsup2yf8dowlb0885mbiq1&name=Mathew" ;
366
+ HttpRequestMessage request = new HttpRequestMessage ( HttpMethod . Get , uri ) ;
367
+ HttpResponseMessage response = await _fixture . HttpClient . SendAsync ( request ) ;
368
+ string initialTimestamp = response . Headers . GetValues ( "Shared-Module" ) . First ( ) ;
369
+
370
+ // make the request again and verify the timestamp is the same
371
+ request = new HttpRequestMessage ( HttpMethod . Get , uri ) ;
372
+ response = await _fixture . HttpClient . SendAsync ( request ) ;
373
+ string timestamp = response . Headers . GetValues ( "Shared-Module" ) . First ( ) ;
374
+ Assert . Equal ( initialTimestamp , timestamp ) ;
375
+
376
+ // now "touch" a file in the shared directory to trigger a restart
377
+ string sharedModulePath = Path . Combine ( _fixture . HostSettings . ScriptPath , "Shared\\ test.js" ) ;
378
+ File . SetLastWriteTimeUtc ( sharedModulePath , DateTime . UtcNow ) ;
379
+
380
+ // wait for the module to be reloaded
381
+ await TestHelpers . Await ( ( ) =>
382
+ {
383
+ request = new HttpRequestMessage ( HttpMethod . Get , uri ) ;
384
+ response = _fixture . HttpClient . SendAsync ( request ) . GetAwaiter ( ) . GetResult ( ) ;
385
+ timestamp = response . Headers . GetValues ( "Shared-Module" ) . First ( ) ;
386
+ return initialTimestamp != timestamp ;
387
+ } , timeout : 5000 , pollingInterval : 1000 ) ;
388
+ Assert . NotEqual ( initialTimestamp , timestamp ) ;
389
+
390
+ initialTimestamp = timestamp ;
391
+ request = new HttpRequestMessage ( HttpMethod . Get , uri ) ;
392
+ response = await _fixture . HttpClient . SendAsync ( request ) ;
393
+ timestamp = response . Headers . GetValues ( "Shared-Module" ) . First ( ) ;
394
+ Assert . Equal ( initialTimestamp , timestamp ) ;
395
+ }
396
+
362
397
[ Fact ]
363
398
public async Task HttpTrigger_CSharp_CustomRoute_ReturnsExpectedResponse ( )
364
399
{
0 commit comments