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: add assertions to integ tests using AwsCustomResource #29950

Merged
merged 21 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { App, Stack, StackProps } from 'aws-cdk-lib/core';
import { IntegTest } from '@aws-cdk/integ-tests-alpha';
import { IntegTest, ExpectedResult } from '@aws-cdk/integ-tests-alpha';
import { Construct } from 'constructs';
import * as synthetics from 'aws-cdk-lib/aws-synthetics';
import { AwsCustomResource, AwsCustomResourcePolicy, PhysicalResourceId } from 'aws-cdk-lib/custom-resources';
Expand All @@ -15,7 +15,7 @@ class TestStack extends Stack {
handler: 'index.handler',
code: synthetics.Code.fromInline(`
exports.handler = async () => {
console.log(\'hello world\');
console.log('hello world');
};`),
}),
cleanup: synthetics.Cleanup.LAMBDA,
Expand All @@ -27,7 +27,7 @@ class TestStack extends Stack {
handler: 'index.handler',
code: synthetics.Code.fromInline(`
exports.handler = async () => {
console.log(\'hello world\');
console.log('hello world');
};`),
}),
cleanup: synthetics.Cleanup.LAMBDA,
Expand All @@ -54,8 +54,21 @@ class TestStack extends Stack {

const app = new App();

new IntegTest(app, 'cdk-integ-synthetics-canary-auto-delete', {
const integTest = new IntegTest(app, 'cdk-integ-synthetics-canary-auto-delete', {
testCases: [new TestStack(app, 'cdk-synthetics-canary-auto-delete')],
diffAssets: true,
stackUpdateWorkflow: false, // will error because this stack has a cr that deletes its own resources
SankyRed marked this conversation as resolved.
Show resolved Hide resolved
stackUpdateWorkflow: false,
});

// Assertion for Canary creation
const canaryAssertion = integTest.assertions.awsApiCall('Synthetics', 'describeCanaries', {
MaxResults: 10, // Adjust this if needed
});

canaryAssertion.expect(ExpectedResult.objectLike({
SankyRed marked this conversation as resolved.
Show resolved Hide resolved
Canaries: [
// As part of this assertion we have check that only one canary exists 'next'
// since 'CanaryRemoved' is cleaned up as part of 'DeleteCanary' custom resource.
{ Name: 'next' },
],
}));

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.