Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(all): replace incorrect property checks in unit tests #1017

Merged
merged 1 commit into from
Oct 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ test("check properties", () => {
const apiGatewayToDynamoDBProps: ApiGatewayToDynamoDBProps = {};
const construct = new ApiGatewayToDynamoDB( stack, "test-api-gateway-dynamodb-default", apiGatewayToDynamoDBProps);

expect(construct.dynamoTable !== null);
expect(construct.apiGateway !== null);
expect(construct.apiGatewayRole !== null);
expect(construct.apiGatewayCloudWatchRole !== null);
expect(construct.apiGatewayLogGroup !== null);
expect(construct.dynamoTable).toBeDefined();
expect(construct.apiGateway).toBeDefined();
expect(construct.apiGatewayRole).toBeDefined();
expect(construct.apiGatewayCloudWatchRole).toBeDefined();
expect(construct.apiGatewayLogGroup).toBeDefined();
});

test("check allow CRUD operations", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ test('Test construct properties', () => {
const stack = new Stack();
const pattern = new ApiGatewayToKinesisStreams(stack, 'api-gateway-kinesis', {});

expect(pattern.apiGateway !== null);
expect(pattern.apiGatewayRole !== null);
expect(pattern.apiGatewayCloudWatchRole !== null);
expect(pattern.apiGatewayLogGroup !== null);
expect(pattern.kinesisStream !== null);
expect(pattern.cloudwatchAlarms !== null);
expect(pattern.apiGateway).toBeDefined();
expect(pattern.apiGatewayRole).toBeDefined();
expect(pattern.apiGatewayCloudWatchRole).toBeDefined();
expect(pattern.apiGatewayLogGroup).toBeDefined();
expect(pattern.kinesisStream).toBeDefined();
expect(pattern.cloudwatchAlarms).toBeDefined();
});

test('Test deployment w/ overwritten properties', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ test('Test properties', () => {
};
const app = new ApiGatewayToLambda(stack, 'test-apigateway-lambda', props);
// Assertion 1
expect(app.lambdaFunction !== null);
expect(app.lambdaFunction).toBeDefined();
// Assertion 2
expect(app.apiGateway !== null);
expect(app.apiGatewayCloudWatchRole !== null);
expect(app.apiGatewayLogGroup !== null);
expect(app.apiGateway).toBeDefined();
expect(app.apiGatewayCloudWatchRole).toBeDefined();
expect(app.apiGatewayLogGroup).toBeDefined();
});

test('Error on lambdaFunctionProps=undefined', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ test('Test construct properties', () => {
requestMappingTemplate: 'my-request-vtl-template'
});

expect(pattern.apiGateway !== null);
expect(pattern.apiGatewayRole !== null);
expect(pattern.apiGatewayCloudWatchRole !== null);
expect(pattern.apiGatewayLogGroup !== null);
expect(pattern.apiGateway).toBeDefined();
expect(pattern.apiGatewayRole).toBeDefined();
expect(pattern.apiGatewayCloudWatchRole).toBeDefined();
expect(pattern.apiGatewayLogGroup).toBeDefined();
});

test('Test deployment w/ overwritten properties', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ test('Test properties', () => {
maxReceiveCount: 3
});
// Assertion 1
expect(pattern.apiGateway !== null);
expect(pattern.apiGateway).toBeDefined();
// Assertion 2
expect(pattern.sqsQueue !== null);
expect(pattern.sqsQueue).toBeDefined();
// Assertion 3
expect(pattern.apiGatewayRole !== null);
expect(pattern.apiGatewayCloudWatchRole !== null);
expect(pattern.apiGatewayLogGroup !== null);
expect(pattern.deadLetterQueue !== null);
expect(pattern.apiGatewayRole).toBeDefined();
expect(pattern.apiGatewayCloudWatchRole).toBeDefined();
expect(pattern.apiGatewayLogGroup).toBeDefined();
expect(pattern.deadLetterQueue).toBeDefined();
});

test('Test deployment ApiGateway AuthorizationType override', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ test('check properties', () => {

const construct: CloudFrontToApiGatewayToLambda = deployNewFunc(stack);

expect(construct.cloudFrontWebDistribution !== null);
expect(construct.apiGateway !== null);
expect(construct.lambdaFunction !== null);
expect(construct.cloudFrontFunction !== null);
expect(construct.cloudFrontLoggingBucket !== null);
expect(construct.apiGatewayCloudWatchRole !== null);
expect(construct.apiGatewayLogGroup !== null);
expect(construct.cloudFrontWebDistribution).toBeDefined();
expect(construct.apiGateway).toBeDefined();
expect(construct.lambdaFunction).toBeDefined();
expect(construct.cloudFrontFunction).toBeDefined();
expect(construct.cloudFrontLoggingBucket).toBeDefined();
expect(construct.apiGatewayCloudWatchRole).toBeDefined();
expect(construct.apiGatewayLogGroup).toBeDefined();
});

test('check lambda function properties for deploy: true', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ test('check getter methods', () => {

const construct: CloudFrontToApiGateway = deploy(stack);

expect(construct.cloudFrontWebDistribution !== null);
expect(construct.apiGateway !== null);
expect(construct.cloudFrontFunction !== null);
expect(construct.cloudFrontLoggingBucket !== null);
expect(construct.cloudFrontWebDistribution).toBeDefined();
expect(construct.apiGateway).toBeDefined();
expect(construct.cloudFrontFunction).toBeDefined();
expect(construct.cloudFrontLoggingBucket).toBeDefined();
});

test('test cloudfront DomainName', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ test('check properties', () => {

const construct: CloudFrontToS3 = deploy(stack);

expect(construct.cloudFrontWebDistribution !== null);
expect(construct.s3Bucket !== null);
expect(construct.cloudFrontWebDistribution).toBeDefined();
expect(construct.s3Bucket).toBeDefined();
});

test("Confirm CheckS3Props is called", () => {
Expand Down Expand Up @@ -173,7 +173,7 @@ test("Test existingBucketObj", () => {
existingBucketObj: s3.Bucket.fromBucketName(stack, 'mybucket', 'mybucket')
});
// Assertion
expect(construct.cloudFrontWebDistribution !== null);
expect(construct.cloudFrontWebDistribution).toBeDefined();
const template = Template.fromStack(stack);
template.hasResourceProperties("AWS::CloudFront::Distribution", {
DistributionConfig: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ test('check properties', () => {

const construct: CognitoToApiGatewayToLambda = deployNewFunc(stack);

expect(construct.userPool !== null);
expect(construct.userPoolClient !== null);
expect(construct.apiGateway !== null);
expect(construct.lambdaFunction !== null);
expect(construct.apiGatewayCloudWatchRole !== null);
expect(construct.apiGatewayLogGroup !== null);
expect(construct.apiGatewayAuthorizer !== null);
expect(construct.userPool).toBeDefined();
expect(construct.userPoolClient).toBeDefined();
expect(construct.apiGateway).toBeDefined();
expect(construct.lambdaFunction).toBeDefined();
expect(construct.apiGatewayCloudWatchRole).toBeDefined();
expect(construct.apiGatewayLogGroup).toBeDefined();
expect(construct.apiGatewayAuthorizer).toBeDefined();
});

test('override cognito cognitoUserPoolClientProps', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@ test('check properties', () => {

const construct: DynamoDBStreamsToLambdaToElasticSearchAndKibana = deployNewFunc(stack);

expect(construct.lambdaFunction !== null);
expect(construct.dynamoTable !== null);
expect(construct.elasticsearchDomain !== null);
expect(construct.elasticsearchRole !== null);
expect(construct.identityPool !== null);
expect(construct.userPool !== null);
expect(construct.userPoolClient !== null);
expect(construct.cloudwatchAlarms !== null);
expect(construct.lambdaFunction).toBeDefined();
expect(construct.dynamoTable).toBeDefined();
expect(construct.elasticsearchDomain).toBeDefined();
expect(construct.elasticsearchRole).toBeDefined();
expect(construct.identityPool).toBeDefined();
expect(construct.userPool).toBeDefined();
expect(construct.userPoolClient).toBeDefined();
expect(construct.cloudwatchAlarms).toBeDefined();
});

test('check exception for Missing existingObj from props for deploy = false', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ test('Test properties', () => {
const construct: EventbridgeToKinesisFirehoseToS3 = deployNewStack(stack);

// Assertions
expect(construct.eventsRule !== null);
expect(construct.eventsRole !== null);
expect(construct.kinesisFirehose !== null);
expect(construct.kinesisFirehoseRole !== null);
expect(construct.kinesisFirehoseLogGroup !== null);
expect(construct.s3Bucket !== null);
expect(construct.s3LoggingBucket !== null);
expect(construct.eventsRule).toBeDefined();
expect(construct.eventsRole).toBeDefined();
expect(construct.kinesisFirehose).toBeDefined();
expect(construct.kinesisFirehoseRole).toBeDefined();
expect(construct.kinesisFirehoseLogGroup).toBeDefined();
expect(construct.s3Bucket).toBeDefined();
expect(construct.s3LoggingBucket).toBeDefined();
});

test('Test default server side s3 bucket encryption', () => {
Expand Down Expand Up @@ -144,14 +144,14 @@ test('check eventbus property, snapshot & eventbus exists', () => {
};
const construct = new EventbridgeToKinesisFirehoseToS3(stack, 'test-eventbridge-kinesis-firehose-default-parameters', props);

expect(construct.eventsRule !== null);
expect(construct.eventsRole !== null);
expect(construct.kinesisFirehose !== null);
expect(construct.kinesisFirehoseRole !== null);
expect(construct.kinesisFirehoseLogGroup !== null);
expect(construct.s3Bucket !== null);
expect(construct.s3LoggingBucket !== null);
expect(construct.eventBus !== null);
expect(construct.eventsRule).toBeDefined();
expect(construct.eventsRole).toBeDefined();
expect(construct.kinesisFirehose).toBeDefined();
expect(construct.kinesisFirehoseRole).toBeDefined();
expect(construct.kinesisFirehoseLogGroup).toBeDefined();
expect(construct.s3Bucket).toBeDefined();
expect(construct.s3LoggingBucket).toBeDefined();
expect(construct.eventBus).toBeDefined();
// Check whether eventbus exists
const template = Template.fromStack(stack);
template.resourceCountIs('AWS::Events::EventBus', 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ test('Test properties', () => {
const construct: EventbridgeToKinesisStreams = deployNewStack(stack);

// Assertions
expect(construct.eventsRule !== null);
expect(construct.kinesisStream !== null);
expect(construct.eventsRole !== null);
expect(construct.eventsRule).toBeDefined();
expect(construct.kinesisStream).toBeDefined();
expect(construct.eventsRole).toBeDefined();
});

test('Test default AWS managed encryption key property', () => {
Expand Down Expand Up @@ -91,10 +91,10 @@ test('check eventbus property, snapshot & eventbus exists', () => {
};
const construct = new EventbridgeToKinesisStreams(stack, 'test-eventbridge-kinesis-streams-default-parameters', props);

expect(construct.eventsRule !== null);
expect(construct.kinesisStream !== null);
expect(construct.eventsRole !== null);
expect(construct.eventBus !== null);
expect(construct.eventsRule).toBeDefined();
expect(construct.kinesisStream).toBeDefined();
expect(construct.eventsRole).toBeDefined();
expect(construct.eventBus).toBeDefined();
// Check whether eventbus exists
const template = Template.fromStack(stack);
template.resourceCountIs('AWS::Events::EventBus', 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ test('check properties', () => {

const construct: EventbridgeToLambda = deployNewFunc(stack);

expect(construct.eventsRule !== null);
expect(construct.lambdaFunction !== null);
expect(construct.eventsRule).toBeDefined();
expect(construct.lambdaFunction).toBeDefined();
});

test('check exception for Missing existingObj from props', () => {
Expand All @@ -209,9 +209,9 @@ test('check eventbus property, snapshot & eventbus exists', () => {

const construct: EventbridgeToLambda = deployNewEventBus(stack);

expect(construct.eventsRule !== null);
expect(construct.lambdaFunction !== null);
expect(construct.eventBus !== null);
expect(construct.eventsRule).toBeDefined();
expect(construct.lambdaFunction).toBeDefined();
expect(construct.eventBus).toBeDefined();
// Check whether eventbus exists
const template = Template.fromStack(stack);
template.resourceCountIs('AWS::Events::EventBus', 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ test('check properties', () => {
const stack = new cdk.Stack();
const construct: EventbridgeToSns = deployNewStack(stack);

expect(construct.eventsRule !== null);
expect(construct.snsTopic !== null);
expect(construct.encryptionKey !== null);
expect(construct.eventsRule).toBeDefined();
expect(construct.snsTopic).toBeDefined();
expect(construct.encryptionKey).toBeDefined();
});

test('check the sns topic properties', () => {
Expand Down Expand Up @@ -224,10 +224,10 @@ test('check eventbus property, snapshot & eventbus exists', () => {

const construct: EventbridgeToSns = deployStackWithNewEventBus(stack);

expect(construct.eventsRule !== null);
expect(construct.snsTopic !== null);
expect(construct.encryptionKey !== null);
expect(construct.eventBus !== null);
expect(construct.eventsRule).toBeDefined();
expect(construct.snsTopic).toBeDefined();
expect(construct.encryptionKey).toBeDefined();
expect(construct.eventBus).toBeDefined();

// Check whether eventbus exists
const template = Template.fromStack(stack);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,21 +278,21 @@ test('check properties', () => {
const stack = new cdk.Stack();
const construct: EventbridgeToSqs = deployNewStack(stack);

expect(construct.eventsRule !== null);
expect(construct.sqsQueue !== null);
expect(construct.encryptionKey !== null);
expect(construct.deadLetterQueue !== null);
expect(construct.eventsRule).toBeDefined();
expect(construct.sqsQueue).toBeDefined();
expect(construct.encryptionKey).toBeDefined();
expect(construct.deadLetterQueue).toBeDefined();
});

test('check eventbus property, snapshot & eventbus exists', () => {
const stack = new cdk.Stack();
const construct: EventbridgeToSqs = deployStackWithNewEventBus(stack);

expect(construct.eventsRule !== null);
expect(construct.sqsQueue !== null);
expect(construct.encryptionKey !== null);
expect(construct.deadLetterQueue !== null);
expect(construct.eventBus !== null);
expect(construct.eventsRule).toBeDefined();
expect(construct.sqsQueue).toBeDefined();
expect(construct.encryptionKey).toBeDefined();
expect(construct.deadLetterQueue).toBeDefined();
expect(construct.eventBus).toBeDefined();

// Check whether eventbus exists
const template = Template.fromStack(stack);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ test('check properties', () => {

const construct: EventbridgeToStepfunctions = deployNewStateMachine(stack);

expect(construct.cloudwatchAlarms !== null);
expect(construct.stateMachine !== null);
expect(construct.eventsRule !== null);
expect(construct.stateMachineLogGroup !== null);
expect(construct.cloudwatchAlarms).toBeDefined();
expect(construct.stateMachine).toBeDefined();
expect(construct.eventsRule).toBeDefined();
expect(construct.stateMachineLogGroup).toBeDefined();
});

test('check properties with no CW Alarms', () => {
Expand All @@ -128,22 +128,22 @@ test('check properties with no CW Alarms', () => {

const construct: EventbridgeToStepfunctions = new EventbridgeToStepfunctions(stack, 'test-eventbridge-stepfunctions', props);

expect(construct.cloudwatchAlarms === null);
expect(construct.stateMachine !== null);
expect(construct.eventsRule !== null);
expect(construct.stateMachineLogGroup !== null);
expect(construct.cloudwatchAlarms).not.toBeDefined();
expect(construct.stateMachine).toBeDefined();
expect(construct.eventsRule).toBeDefined();
expect(construct.stateMachineLogGroup).toBeDefined();
});

test('check eventbus property, snapshot & eventbus exists', () => {
const stack = new cdk.Stack();

const construct: EventbridgeToStepfunctions = deployNewStateMachineAndEventBus(stack);

expect(construct.cloudwatchAlarms !== null);
expect(construct.stateMachine !== null);
expect(construct.eventsRule !== null);
expect(construct.stateMachineLogGroup !== null);
expect(construct.eventBus !== null);
expect(construct.cloudwatchAlarms).toBeDefined();
expect(construct.stateMachine).toBeDefined();
expect(construct.eventsRule).toBeDefined();
expect(construct.stateMachineLogGroup).toBeDefined();
expect(construct.eventBus).toBeDefined();

// Check whether eventbus exists
const template = Template.fromStack(stack);
Expand Down
Loading