@@ -36,6 +36,7 @@ public class FunctionsSyncManagerTests : IDisposable
36
36
private readonly MockHttpHandler _mockHttpHandler ;
37
37
private readonly TestLoggerProvider _loggerProvider ;
38
38
private readonly Mock < ScriptSettingsManager > _scriptSettingsManagerMock ;
39
+ private string _function1 ;
39
40
40
41
public FunctionsSyncManagerTests ( )
41
42
{
@@ -142,6 +143,27 @@ public async Task TrySyncTriggers_StandbyMode_ReturnsFalse()
142
143
}
143
144
}
144
145
146
+ [ Fact ]
147
+ public async Task TrySyncTriggers_MaxSyncTriggersPayloadSize_Succeeds ( )
148
+ {
149
+ // create a dummy file that pushes us over size
150
+ string maxString = new string ( 'x' , ScriptConstants . MaxTriggersStringLength + 1 ) ;
151
+ _function1 = $ "{{ bindings: [], test: '{ maxString } '}}";
152
+
153
+ using ( var env = new TestScopedEnvironmentVariable ( _vars ) )
154
+ {
155
+ Assert . True ( _functionsSyncManager . ArmCacheEnabled ) ;
156
+
157
+ var result = await _functionsSyncManager . TrySyncTriggersAsync ( ) ;
158
+ Assert . True ( result . Success ) ;
159
+
160
+ string syncString = _contentBuilder . ToString ( ) ;
161
+ Assert . True ( syncString . Length < ScriptConstants . MaxTriggersStringLength ) ;
162
+ var syncContent = JToken . Parse ( syncString ) ;
163
+ Assert . Equal ( JTokenType . Array , syncContent . Type ) ;
164
+ }
165
+ }
166
+
145
167
[ Fact ]
146
168
public async Task TrySyncTriggers_LocalEnvironment_ReturnsFalse ( )
147
169
{
@@ -421,7 +443,7 @@ private static HttpClient CreateHttpClient(MockHttpHandler httpHandler)
421
443
return new HttpClient ( httpHandler ) ;
422
444
}
423
445
424
- private static IFileSystem CreateFileSystem ( ScriptHostConfiguration hostConfig , string hostJsonContent = null )
446
+ private IFileSystem CreateFileSystem ( ScriptHostConfiguration hostConfig , string hostJsonContent = null )
425
447
{
426
448
string rootScriptPath = hostConfig . RootScriptPath ;
427
449
string testDataPath = hostConfig . TestDataPath ;
@@ -450,7 +472,7 @@ private static IFileSystem CreateFileSystem(ScriptHostConfiguration hostConfig,
450
472
Path . Combine ( rootScriptPath , "function3" )
451
473
} ) ;
452
474
453
- var function1 = @"{
475
+ _function1 = @"{
454
476
""scriptFile"": ""main.py"",
455
477
""disabled"": false,
456
478
""bindings"": [
@@ -497,14 +519,14 @@ private static IFileSystem CreateFileSystem(ScriptHostConfiguration hostConfig,
497
519
498
520
fileBase . Setup ( f => f . Exists ( Path . Combine ( rootScriptPath , @"function1\function.json" ) ) ) . Returns ( true ) ;
499
521
fileBase . Setup ( f => f . Exists ( Path . Combine ( rootScriptPath , @"function1\main.py" ) ) ) . Returns ( true ) ;
500
- fileBase . Setup ( f => f . ReadAllText ( Path . Combine ( rootScriptPath , @"function1\function.json" ) ) ) . Returns ( function1 ) ;
522
+ fileBase . Setup ( f => f . ReadAllText ( Path . Combine ( rootScriptPath , @"function1\function.json" ) ) ) . Returns ( _function1 ) ;
501
523
fileBase . Setup ( f => f . Open ( Path . Combine ( rootScriptPath , @"function1\function.json" ) , It . IsAny < FileMode > ( ) , It . IsAny < FileAccess > ( ) , It . IsAny < FileShare > ( ) ) ) . Returns ( ( ) =>
502
524
{
503
- return new MemoryStream ( Encoding . UTF8 . GetBytes ( function1 ) ) ;
525
+ return new MemoryStream ( Encoding . UTF8 . GetBytes ( _function1 ) ) ;
504
526
} ) ;
505
527
fileBase . Setup ( f => f . Open ( Path . Combine ( testDataPath , "function1.dat" ) , It . IsAny < FileMode > ( ) , It . IsAny < FileAccess > ( ) , It . IsAny < FileShare > ( ) ) ) . Returns ( ( ) =>
506
528
{
507
- return new MemoryStream ( Encoding . UTF8 . GetBytes ( function1 ) ) ;
529
+ return new MemoryStream ( Encoding . UTF8 . GetBytes ( _function1 ) ) ;
508
530
} ) ;
509
531
510
532
fileBase . Setup ( f => f . Exists ( Path . Combine ( rootScriptPath , @"function2\function.json" ) ) ) . Returns ( true ) ;
@@ -516,7 +538,7 @@ private static IFileSystem CreateFileSystem(ScriptHostConfiguration hostConfig,
516
538
} ) ;
517
539
fileBase . Setup ( f => f . Open ( Path . Combine ( testDataPath , "function2.dat" ) , It . IsAny < FileMode > ( ) , It . IsAny < FileAccess > ( ) , It . IsAny < FileShare > ( ) ) ) . Returns ( ( ) =>
518
540
{
519
- return new MemoryStream ( Encoding . UTF8 . GetBytes ( function1 ) ) ;
541
+ return new MemoryStream ( Encoding . UTF8 . GetBytes ( _function1 ) ) ;
520
542
} ) ;
521
543
522
544
fileBase . Setup ( f => f . Exists ( Path . Combine ( rootScriptPath , @"function3\function.json" ) ) ) . Returns ( true ) ;
@@ -528,7 +550,7 @@ private static IFileSystem CreateFileSystem(ScriptHostConfiguration hostConfig,
528
550
} ) ;
529
551
fileBase . Setup ( f => f . Open ( Path . Combine ( testDataPath , "function3.dat" ) , It . IsAny < FileMode > ( ) , It . IsAny < FileAccess > ( ) , It . IsAny < FileShare > ( ) ) ) . Returns ( ( ) =>
530
552
{
531
- return new MemoryStream ( Encoding . UTF8 . GetBytes ( function1 ) ) ;
553
+ return new MemoryStream ( Encoding . UTF8 . GetBytes ( _function1 ) ) ;
532
554
} ) ;
533
555
534
556
return fileSystem . Object ;
0 commit comments