Skip to content

Commit

Permalink
Add validation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tomoish committed Dec 11, 2023
1 parent f0273f8 commit 7110b67
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions packages/aws-cdk-lib/aws-lambda/test/logging-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,4 +225,35 @@ describe('logging Config', () => {
},
});
});

test('Throws when invalid logFormat is specified', () => {
const app = new cdk.App();
const stack = new cdk.Stack(app, 'stack');
expect(() => {
new lambda.Function(stack, 'Lambda', {
code: new lambda.InlineCode('foo'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_18_X,
logFormat: 'XML',
});
}).toThrow(/'XML' is not a legal LogFormat type./);
});

test('Throws when invalid logFormat is specified in getLoggingConfig', () => {
const app = new cdk.App();
const stack = new cdk.Stack(app, 'stack');
expect(() => {
const lambdaFunction = new lambda.Function(stack, 'Lambda', {
code: new lambda.InlineCode('foo'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_18_X,
});
(lambdaFunction as any).getLoggingConfig({
code: new lambda.InlineCode('foo'),
handler: 'index.handler',
runtime: lambda.Runtime.NODEJS_18_X,
logFormat: 'XML',
});
}).toThrow(/'XML' is not a legal LogFormat type./);
});
});

0 comments on commit 7110b67

Please sign in to comment.