Skip to content

Commit

Permalink
chore(lambda-nodejs): migrate tests to assertions (#18497)
Browse files Browse the repository at this point in the history
----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
corymhall authored Jan 19, 2022
1 parent 03d388d commit 3f87b4d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-lambda-nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
},
"license": "Apache-2.0",
"devDependencies": {
"@aws-cdk/assert-internal": "0.0.0",
"@aws-cdk/assertions": "0.0.0",
"@aws-cdk/aws-ec2": "0.0.0",
"@aws-cdk/cdk-build-tools": "0.0.0",
"@aws-cdk/cdk-integ-tools": "0.0.0",
Expand Down
13 changes: 6 additions & 7 deletions packages/@aws-cdk/aws-lambda-nodejs/test/function.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import '@aws-cdk/assert-internal/jest';
import * as fs from 'fs';
import * as path from 'path';
import { ABSENT } from '@aws-cdk/assert-internal';
import { Template, Match } from '@aws-cdk/assertions';
import { Vpc } from '@aws-cdk/aws-ec2';
import { CodeConfig, Runtime } from '@aws-cdk/aws-lambda';
import { Stack } from '@aws-cdk/core';
Expand Down Expand Up @@ -40,7 +39,7 @@ test('NodejsFunction with .ts handler', () => {
entry: expect.stringContaining('function.test.handler1.ts'), // Automatically finds .ts handler file
}));

expect(stack).toHaveResource('AWS::Lambda::Function', {
Template.fromStack(stack).hasResourceProperties('AWS::Lambda::Function', {
Handler: 'index.handler',
Runtime: 'nodejs14.x',
});
Expand Down Expand Up @@ -155,7 +154,7 @@ test('configures connection reuse for aws sdk', () => {
// WHEN
new NodejsFunction(stack, 'handler1');

expect(stack).toHaveResource('AWS::Lambda::Function', {
Template.fromStack(stack).hasResourceProperties('AWS::Lambda::Function', {
Environment: {
Variables: {
AWS_NODEJS_CONNECTION_REUSE_ENABLED: '1',
Expand All @@ -170,8 +169,8 @@ test('can opt-out of connection reuse for aws sdk', () => {
awsSdkConnectionReuse: false,
});

expect(stack).toHaveResource('AWS::Lambda::Function', {
Environment: ABSENT,
Template.fromStack(stack).hasResourceProperties('AWS::Lambda::Function', {
Environment: Match.absent(),
});
});

Expand All @@ -183,7 +182,7 @@ test('NodejsFunction in a VPC', () => {
new NodejsFunction(stack, 'handler1', { vpc });

// THEN
expect(stack).toHaveResource('AWS::Lambda::Function', {
Template.fromStack(stack).hasResourceProperties('AWS::Lambda::Function', {
VpcConfig: {
SecurityGroupIds: [
{
Expand Down

0 comments on commit 3f87b4d

Please sign in to comment.