@@ -15,6 +15,12 @@ describe('Class: Utility', () => {
1515 public validateServiceName ( serviceName : string ) : boolean {
1616 return this . isValidServiceName ( serviceName ) ;
1717 }
18+ public getInitializationType ( ) :
19+ | 'unknown'
20+ | 'on-demand'
21+ | 'provisioned-concurrency' {
22+ return super . getInitializationType ( ) ;
23+ }
1824 }
1925
2026 it ( 'returns the correct cold start value' , ( ) => {
@@ -27,6 +33,15 @@ describe('Class: Utility', () => {
2733 expect ( utility . dummyMethod ( ) ) . toBe ( false ) ;
2834 } ) ;
2935
36+ it ( 'returns the correct cold start value when provisioned concurrency is used' , ( ) => {
37+ // Prepare
38+ process . env . AWS_LAMBDA_INITIALIZATION_TYPE = 'provisioned-concurrency' ;
39+ const utility = new TestUtility ( ) ;
40+
41+ // Act & Assess
42+ expect ( utility . dummyMethod ( ) ) . toBe ( false ) ;
43+ } ) ;
44+
3045 it ( 'flips the cold start value' , ( ) => {
3146 // Prepare
3247 const utility = new TestUtility ( ) ;
@@ -54,4 +69,23 @@ describe('Class: Utility', () => {
5469 expect ( utility . validateServiceName ( 'serverlessAirline' ) ) . toBe ( true ) ;
5570 expect ( utility . validateServiceName ( '' ) ) . toBe ( false ) ;
5671 } ) ;
72+
73+ it . each ( [
74+ { value : 'on-demand' , expected : 'on-demand' } ,
75+ { value : 'provisioned-concurrency' , expected : 'provisioned-concurrency' } ,
76+ { value : '' , expected : 'unknown' } ,
77+ ] ) (
78+ 'returns the correct initialization type ($value)' ,
79+ ( { value, expected } ) => {
80+ // Prepare
81+ process . env . AWS_LAMBDA_INITIALIZATION_TYPE = value ;
82+ const utility = new TestUtility ( ) ;
83+
84+ // Act
85+ const initializationType = utility . getInitializationType ( ) ;
86+
87+ // Assess
88+ expect ( initializationType ) . toBe ( expected ) ;
89+ }
90+ ) ;
5791} ) ;
0 commit comments