@@ -293,6 +293,47 @@ public void Create_InvalidHostJson_ThrowsInformativeException()
293
293
Assert . Equal ( "Invalid property identifier character: ~. Path '', line 2, position 4." , ex . InnerException . Message ) ;
294
294
}
295
295
296
+ [ Theory ]
297
+ [ InlineData ( "host" ) ]
298
+ [ InlineData ( "-function" ) ]
299
+ [ InlineData ( "_function" ) ]
300
+ [ InlineData ( "function test" ) ]
301
+ [ InlineData ( "function.test" ) ]
302
+ [ InlineData ( "function0.1" ) ]
303
+ public void Create_InvalidFunctionNames_DoesNotCreateFunctionAndLogsFailure ( string functionName )
304
+ {
305
+ string rootPath = Path . Combine ( Path . GetTempPath ( ) , Guid . NewGuid ( ) . ToString ( ) ) ;
306
+ string invalidFunctionNamePath = Path . Combine ( rootPath , functionName ) ;
307
+ try
308
+ {
309
+ Directory . CreateDirectory ( invalidFunctionNamePath ) ;
310
+
311
+ JObject config = new JObject ( ) ;
312
+ config [ "id" ] = ID ;
313
+
314
+ File . WriteAllText ( Path . Combine ( rootPath , ScriptConstants . HostMetadataFileName ) , config . ToString ( ) ) ;
315
+ File . WriteAllText ( Path . Combine ( invalidFunctionNamePath , ScriptConstants . FunctionMetadataFileName ) , string . Empty ) ;
316
+
317
+ ScriptHostConfiguration scriptConfig = new ScriptHostConfiguration ( )
318
+ {
319
+ RootScriptPath = rootPath
320
+ } ;
321
+
322
+ var scriptHost = ScriptHost . Create ( _settingsManager , scriptConfig ) ;
323
+
324
+ Assert . Equal ( 1 , scriptHost . FunctionErrors . Count ) ;
325
+ Assert . Equal ( functionName , scriptHost . FunctionErrors . First ( ) . Key ) ;
326
+ Assert . Equal ( $ "'{ functionName } ' is not a valid function name.", scriptHost . FunctionErrors . First ( ) . Value . First ( ) ) ;
327
+ }
328
+ finally
329
+ {
330
+ if ( Directory . Exists ( rootPath ) )
331
+ {
332
+ Directory . Delete ( rootPath , true ) ;
333
+ }
334
+ }
335
+ }
336
+
296
337
[ Fact ]
297
338
public void ApplyConfiguration_TopLevel ( )
298
339
{
@@ -612,6 +653,8 @@ public void TryGetFunctionFromException_FunctionMatch()
612
653
[ InlineData ( "-function" ) ]
613
654
[ InlineData ( "_function" ) ]
614
655
[ InlineData ( "function test" ) ]
656
+ [ InlineData ( "function.test" ) ]
657
+ [ InlineData ( "function0.1" ) ]
615
658
public void ValidateFunctionName_ThrowsOnInvalidName ( string functionName )
616
659
{
617
660
var ex = Assert . Throws < InvalidOperationException > ( ( ) =>
0 commit comments