Skip to content

Commit

Permalink
test(hcl2cdk): add test case for property renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielMSchmidt committed Apr 11, 2022
1 parent 3cf9fcc commit 044b1da
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 2 deletions.
37 changes: 37 additions & 0 deletions packages/@cdktf/hcl2cdk/test/__snapshots__/hcl2cdk.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,43 @@ new aws.s3.S3Bucket(this, \\"examplebucket\\", {
"
`;
exports[`convert property level renamings snapshot 1`] = `
"/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
import * as aws from \\"./.gen/providers/aws\\";
new aws.AwsProvider(this, \\"aws\\", {
region: \\"us-east-1\\",
});
new aws.guardduty.GuarddutyFilter(this, \\"MyFilter\\", {
action: \\"ARCHIVE\\",
detectorId: \\"id\\",
findingCriteria: {
criterion: [
{
equals: [\\"eu-west-1\\"],
field: \\"region\\",
},
{
field: \\"service.additionalInfo.threatListName\\",
notEquals: [\\"some-threat\\", \\"another-threat\\"],
},
{
field: \\"updatedAt\\",
greaterThan: \\"2020-01-01T00:00:00Z\\",
lessThan: \\"2020-02-01T00:00:00Z\\",
},
{
field: \\"severity\\",
greaterThanOrEqual: \\"4\\",
},
],
},
name: \\"MyFilter\\",
rank: 1,
});
"
`;
exports[`convert provider alias snapshot 1`] = `
"/*Provider bindings are generated by running cdktf get.
See https://cdk.tf/provider-generation for more details.*/
Expand Down
44 changes: 42 additions & 2 deletions packages/@cdktf/hcl2cdk/test/hcl2cdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ enum Synth {
yes,
needsAFix_BooleanAsIResolvable, // https://github.com/hashicorp/terraform-cdk/issues/1550
needsAFix_MaximumCallStackSizeExceeded, // https://github.com/hashicorp/terraform-cdk/issues/1551
needsAFix_UnforseenRename, // https://github.com/hashicorp/terraform-cdk/issues/1552
needsAFix_UnforseenClassRename, // https://github.com/hashicorp/terraform-cdk/issues/1552
needsAFix_UnforseenPropertyRename, // https://github.com/hashicorp/terraform-cdk/issues/1708
needsAFix_StringIsNotAssignableToListOfString, // https://github.com/hashicorp/terraform-cdk/issues/1553
never, // Some examples are built so that they will never synth but test a specific generation edge case
}
Expand Down Expand Up @@ -1150,7 +1151,7 @@ describe("convert", () => {
display_name = each.key
}
`,
Synth.needsAFix_UnforseenRename
Synth.needsAFix_UnforseenClassRename
);

testCase.test(
Expand Down Expand Up @@ -1294,6 +1295,45 @@ describe("convert", () => {
Synth.yes
);

testCase.test(
"property level renamings",
`
provider "aws" {
region = "us-east-1"
}
resource "aws_guardduty_filter" "MyFilter" {
name = "MyFilter"
action = "ARCHIVE"
detector_id = "id"
rank = 1
finding_criteria {
criterion {
field = "region"
equals = ["eu-west-1"]
}
criterion {
field = "service.additionalInfo.threatListName"
not_equals = ["some-threat", "another-threat"]
}
criterion {
field = "updatedAt"
greater_than = "2020-01-01T00:00:00Z"
less_than = "2020-02-01T00:00:00Z"
}
criterion {
field = "severity"
greater_than_or_equal = "4"
}
}
}
`,
Synth.needsAFix_UnforseenPropertyRename
);

const targetLanguages = ["typescript", "python", "csharp", "java"];
describe("Cross-Language Support", () => {
it.each(targetLanguages)("supports %s", (language) => {
Expand Down

0 comments on commit 044b1da

Please sign in to comment.