@@ -40,6 +40,7 @@ public class FunctionsSyncManagerTests : IDisposable
40
40
private readonly Mock < IScriptWebHostEnvironment > _mockWebHostEnvironment ;
41
41
private readonly Mock < IEnvironment > _mockEnvironment ;
42
42
private readonly HostNameProvider _hostNameProvider ;
43
+ private string _function1 ;
43
44
44
45
public FunctionsSyncManagerTests ( )
45
46
{
@@ -139,6 +140,27 @@ public async Task TrySyncTriggers_StandbyMode_ReturnsFalse()
139
140
}
140
141
}
141
142
143
+ [ Fact ]
144
+ public async Task TrySyncTriggers_MaxSyncTriggersPayloadSize_Succeeds ( )
145
+ {
146
+ // create a dummy file that pushes us over size
147
+ string maxString = new string ( 'x' , ScriptConstants . MaxTriggersStringLength + 1 ) ;
148
+ _function1 = $ "{{ bindings: [], test: '{ maxString } '}}";
149
+
150
+ using ( var env = new TestScopedEnvironmentVariable ( _vars ) )
151
+ {
152
+ Assert . True ( _functionsSyncManager . ArmCacheEnabled ) ;
153
+
154
+ var result = await _functionsSyncManager . TrySyncTriggersAsync ( ) ;
155
+ Assert . True ( result . Success ) ;
156
+
157
+ string syncString = _contentBuilder . ToString ( ) ;
158
+ Assert . True ( syncString . Length < ScriptConstants . MaxTriggersStringLength ) ;
159
+ var syncContent = JToken . Parse ( syncString ) ;
160
+ Assert . Equal ( JTokenType . Array , syncContent . Type ) ;
161
+ }
162
+ }
163
+
142
164
[ Fact ]
143
165
public async Task TrySyncTriggers_LocalEnvironment_ReturnsFalse ( )
144
166
{
@@ -370,9 +392,9 @@ private static LanguageWorkerOptions CreateLanguageWorkerConfigSettings()
370
392
} ;
371
393
}
372
394
373
- private static IFileSystem CreateFileSystem ( ScriptApplicationHostOptions hostOptions , string hostJsonContent = null )
395
+ private IFileSystem CreateFileSystem ( ScriptApplicationHostOptions hostOptions , string hostJsonContent = null )
374
396
{
375
- string rootPath = hostOptions . ScriptPath ;
397
+ var rootPath = hostOptions . ScriptPath ;
376
398
string testDataPath = hostOptions . TestDataPath ;
377
399
378
400
var fullFileSystem = new FileSystem ( ) ;
@@ -412,7 +434,7 @@ private static IFileSystem CreateFileSystem(ScriptApplicationHostOptions hostOpt
412
434
Path . Combine ( rootPath , "function3" )
413
435
} ) ;
414
436
415
- var function1 = @"{
437
+ _function1 = @"{
416
438
""scriptFile"": ""main.py"",
417
439
""disabled"": false,
418
440
""bindings"": [
@@ -459,14 +481,14 @@ private static IFileSystem CreateFileSystem(ScriptApplicationHostOptions hostOpt
459
481
460
482
fileBase . Setup ( f => f . Exists ( Path . Combine ( rootPath , @"function1\function.json" ) ) ) . Returns ( true ) ;
461
483
fileBase . Setup ( f => f . Exists ( Path . Combine ( rootPath , @"function1\main.py" ) ) ) . Returns ( true ) ;
462
- fileBase . Setup ( f => f . ReadAllText ( Path . Combine ( rootPath , @"function1\function.json" ) ) ) . Returns ( function1 ) ;
484
+ fileBase . Setup ( f => f . ReadAllText ( Path . Combine ( rootPath , @"function1\function.json" ) ) ) . Returns ( _function1 ) ;
463
485
fileBase . Setup ( f => f . Open ( Path . Combine ( rootPath , @"function1\function.json" ) , It . IsAny < FileMode > ( ) , It . IsAny < FileAccess > ( ) , It . IsAny < FileShare > ( ) ) ) . Returns ( ( ) =>
464
486
{
465
- return new MemoryStream ( Encoding . UTF8 . GetBytes ( function1 ) ) ;
487
+ return new MemoryStream ( Encoding . UTF8 . GetBytes ( _function1 ) ) ;
466
488
} ) ;
467
489
fileBase . Setup ( f => f . Open ( Path . Combine ( testDataPath , "function1.dat" ) , It . IsAny < FileMode > ( ) , It . IsAny < FileAccess > ( ) , It . IsAny < FileShare > ( ) ) ) . Returns ( ( ) =>
468
490
{
469
- return new MemoryStream ( Encoding . UTF8 . GetBytes ( function1 ) ) ;
491
+ return new MemoryStream ( Encoding . UTF8 . GetBytes ( _function1 ) ) ;
470
492
} ) ;
471
493
472
494
fileBase . Setup ( f => f . Exists ( Path . Combine ( rootPath , @"function2\function.json" ) ) ) . Returns ( true ) ;
@@ -478,7 +500,7 @@ private static IFileSystem CreateFileSystem(ScriptApplicationHostOptions hostOpt
478
500
} ) ;
479
501
fileBase . Setup ( f => f . Open ( Path . Combine ( testDataPath , "function2.dat" ) , It . IsAny < FileMode > ( ) , It . IsAny < FileAccess > ( ) , It . IsAny < FileShare > ( ) ) ) . Returns ( ( ) =>
480
502
{
481
- return new MemoryStream ( Encoding . UTF8 . GetBytes ( function1 ) ) ;
503
+ return new MemoryStream ( Encoding . UTF8 . GetBytes ( _function1 ) ) ;
482
504
} ) ;
483
505
484
506
fileBase . Setup ( f => f . Exists ( Path . Combine ( rootPath , @"function3\function.json" ) ) ) . Returns ( true ) ;
@@ -490,7 +512,7 @@ private static IFileSystem CreateFileSystem(ScriptApplicationHostOptions hostOpt
490
512
} ) ;
491
513
fileBase . Setup ( f => f . Open ( Path . Combine ( testDataPath , "function3.dat" ) , It . IsAny < FileMode > ( ) , It . IsAny < FileAccess > ( ) , It . IsAny < FileShare > ( ) ) ) . Returns ( ( ) =>
492
514
{
493
- return new MemoryStream ( Encoding . UTF8 . GetBytes ( function1 ) ) ;
515
+ return new MemoryStream ( Encoding . UTF8 . GetBytes ( _function1 ) ) ;
494
516
} ) ;
495
517
496
518
return fileSystem . Object ;
0 commit comments