Skip to content

Commit

Permalink
resource ir cidr string unit test hava
Browse files Browse the repository at this point in the history
Signed-off-by: Francis <colifran@amazon.com>
  • Loading branch information
colifran committed Mar 31, 2024
1 parent 6abebf2 commit 692696e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 40 deletions.
13 changes: 13 additions & 0 deletions src/synthesizer/java/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,16 @@ fn test_resource_ir_cidr_null_mask() {
let result = emit_java(resource_ir, &output, Option::None, &schema);
assert_eq!((), result.unwrap());
}

#[test]
fn test_resource_ir_cidr_string_mask() {
let output = CodeBuffer::default();
let schema = Cow::Borrowed(Schema::builtin());
let resource_ir = ResourceIr::Cidr(
Box::new(ResourceIr::String("0.0.0.0".into())),
Box::new(ResourceIr::String("16".into())),
Box::new(ResourceIr::String("255.255.255.0".into())),
);
let result = emit_java(resource_ir, &output, Option::None, &schema);
assert_eq!((), result.unwrap());
}
40 changes: 0 additions & 40 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -867,43 +867,3 @@ fn test_update_policy_java() {
let result = ir.synthesize(synthesizer.as_ref(), &mut output, "Stack");
assert_eq!((), result.unwrap());
}

#[test]
fn test_resource_condition_java() {
let cfn_template = json!({
"Conditions": {
"CreateResourceCondition": {
"Fn::Equals": [
{
"Ref": "CreateResourceParameter"
},
"true"
]
}
},
"Parameters": {
"CreateResourceParameter": {
"Type": "String",
"Default": "true",
"AllowedValues": ["true", "false"]
}
},
"Resources": {
"MyResource": {
"Type": "AWS::EC2::Instance",
"Condition": "CreateResourceCondition",
"Properties": {
"InstanceType": "t2.micro",
"ImageId": "ami-12345678"
}
}
}
});
let cfn_tree: CloudformationParseTree = serde_yaml::from_value(cfn_template).unwrap();
let schema = Cow::Borrowed(Schema::builtin());
let ir = CloudformationProgramIr::from(cfn_tree, &schema).unwrap();
let synthesizer = Box::<Java>::default();
let mut output = Vec::new();
let result = ir.synthesize(synthesizer.as_ref(), &mut output, "Stack");
assert_eq!((), result.unwrap());
}

0 comments on commit 692696e

Please sign in to comment.