@@ -133,6 +133,60 @@ describe('logging Config', () => {
133
133
logGroupName : 'customLogGroup' ,
134
134
} ) ,
135
135
} ) ;
136
- } ) . toThrowError ( 'CDK does not support setting logRetention and logGroup' ) ;
136
+ } ) . toThrow ( / C D K d o e s n o t s u p p o r t s e t t i n g l o g R e t e n t i o n a n d l o g G r o u p / ) ;
137
+ } ) ;
138
+
139
+ test ( 'Throws when applicationLogLevel is specified with TEXT logFormat' , ( ) => {
140
+ const app = new cdk . App ( ) ;
141
+ const stack = new cdk . Stack ( app , 'stack' ) ;
142
+ expect ( ( ) => {
143
+ new lambda . Function ( stack , 'Lambda' , {
144
+ code : new lambda . InlineCode ( 'foo' ) ,
145
+ handler : 'index.handler' ,
146
+ runtime : lambda . Runtime . NODEJS_18_X ,
147
+ logFormat : lambda . LogFormat . TEXT ,
148
+ applicationLogLevel : lambda . ApplicationLogLevel . INFO ,
149
+ } ) ;
150
+ } ) . toThrow ( / A p p l i c a t i o n L o g L e v e l a n d S y s t e m L o g L e v e l c a n n o t b e s p e c i f i e d w i t h o u t L o g F o r m a t b e i n g s e t t o J S O N ./ ) ;
151
+ } ) ;
152
+
153
+ test ( 'Throws when systemLogLevel is specified with TEXT logFormat' , ( ) => {
154
+ const app = new cdk . App ( ) ;
155
+ const stack = new cdk . Stack ( app , 'stack' ) ;
156
+ expect ( ( ) => {
157
+ new lambda . Function ( stack , 'Lambda' , {
158
+ code : new lambda . InlineCode ( 'foo' ) ,
159
+ handler : 'index.handler' ,
160
+ runtime : lambda . Runtime . NODEJS_18_X ,
161
+ logFormat : lambda . LogFormat . TEXT ,
162
+ systemLogLevel : lambda . SystemLogLevel . INFO ,
163
+ } ) ;
164
+ } ) . toThrow ( / A p p l i c a t i o n L o g L e v e l a n d S y s t e m L o g L e v e l c a n n o t b e s p e c i f i e d w i t h o u t L o g F o r m a t b e i n g s e t t o J S O N ./ ) ;
165
+ } ) ;
166
+
167
+ test ( 'Throws when applicationLogLevel is specified if logFormat is undefined' , ( ) => {
168
+ const app = new cdk . App ( ) ;
169
+ const stack = new cdk . Stack ( app , 'stack' ) ;
170
+ expect ( ( ) => {
171
+ new lambda . Function ( stack , 'Lambda' , {
172
+ code : new lambda . InlineCode ( 'foo' ) ,
173
+ handler : 'index.handler' ,
174
+ runtime : lambda . Runtime . NODEJS_18_X ,
175
+ applicationLogLevel : lambda . ApplicationLogLevel . INFO ,
176
+ } ) ;
177
+ } ) . toThrow ( / A p p l i c a t i o n L o g L e v e l a n d S y s t e m L o g L e v e l c a n n o t b e s p e c i f i e d w i t h o u t L o g F o r m a t b e i n g s e t t o J S O N ./ ) ;
178
+ } ) ;
179
+
180
+ test ( 'Throws when systemLogLevel is specified if logFormat is undefined' , ( ) => {
181
+ const app = new cdk . App ( ) ;
182
+ const stack = new cdk . Stack ( app , 'stack' ) ;
183
+ expect ( ( ) => {
184
+ new lambda . Function ( stack , 'Lambda' , {
185
+ code : new lambda . InlineCode ( 'foo' ) ,
186
+ handler : 'index.handler' ,
187
+ runtime : lambda . Runtime . NODEJS_18_X ,
188
+ systemLogLevel : lambda . SystemLogLevel . INFO ,
189
+ } ) ;
190
+ } ) . toThrow ( / A p p l i c a t i o n L o g L e v e l a n d S y s t e m L o g L e v e l c a n n o t b e s p e c i f i e d w i t h o u t L o g F o r m a t b e i n g s e t t o J S O N ./ ) ;
137
191
} ) ;
138
192
} ) ;
0 commit comments