@@ -15,6 +15,12 @@ describe('Class: Utility', () => {
15
15
public validateServiceName ( serviceName : string ) : boolean {
16
16
return this . isValidServiceName ( serviceName ) ;
17
17
}
18
+ public getInitializationType ( ) :
19
+ | 'unknown'
20
+ | 'on-demand'
21
+ | 'provisioned-concurrency' {
22
+ return super . getInitializationType ( ) ;
23
+ }
18
24
}
19
25
20
26
it ( 'returns the correct cold start value' , ( ) => {
@@ -27,6 +33,15 @@ describe('Class: Utility', () => {
27
33
expect ( utility . dummyMethod ( ) ) . toBe ( false ) ;
28
34
} ) ;
29
35
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
+
30
45
it ( 'flips the cold start value' , ( ) => {
31
46
// Prepare
32
47
const utility = new TestUtility ( ) ;
@@ -54,4 +69,23 @@ describe('Class: Utility', () => {
54
69
expect ( utility . validateServiceName ( 'serverlessAirline' ) ) . toBe ( true ) ;
55
70
expect ( utility . validateServiceName ( '' ) ) . toBe ( false ) ;
56
71
} ) ;
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
+ ) ;
57
91
} ) ;
0 commit comments