@@ -2648,6 +2648,31 @@ describe('function', () => {
2648
2648
} ) . not . toThrow ( ) ;
2649
2649
} ) ;
2650
2650
2651
+ test ( 'Error when function description is longer than 256 chars' , ( ) => {
2652
+ const stack = new cdk . Stack ( ) ;
2653
+ expect ( ( ) => new lambda . Function ( stack , 'MyFunction' , {
2654
+ code : lambda . Code . fromInline ( 'foo' ) ,
2655
+ runtime : lambda . Runtime . NODEJS_14_X ,
2656
+ handler : 'index.handler' ,
2657
+ description : 'a' . repeat ( 257 ) ,
2658
+ } ) ) . toThrow ( / F u n c t i o n d e s c r i p t i o n c a n n o t b e l o n g e r t h a n 2 5 6 c h a r a c t e r s / ) ;
2659
+ } ) ;
2660
+
2661
+ test ( 'No error when function name is Tokenized and Unresolved' , ( ) => {
2662
+ const stack = new cdk . Stack ( ) ;
2663
+ expect ( ( ) => {
2664
+ const realFunctionDescription = 'a' . repeat ( 257 ) ;
2665
+ const tokenizedFunctionDescription = cdk . Token . asString ( new cdk . Intrinsic ( realFunctionDescription ) ) ;
2666
+
2667
+ new lambda . Function ( stack , 'foo' , {
2668
+ code : new lambda . InlineCode ( 'foo' ) ,
2669
+ handler : 'index.handler' ,
2670
+ runtime : lambda . Runtime . NODEJS_14_X ,
2671
+ description : tokenizedFunctionDescription ,
2672
+ } ) ;
2673
+ } ) . not . toThrow ( ) ;
2674
+ } ) ;
2675
+
2651
2676
describe ( 'FunctionUrl' , ( ) => {
2652
2677
test ( 'addFunctionUrl creates a function url with default options' , ( ) => {
2653
2678
// GIVEN
0 commit comments