Skip to content

Commit

Permalink
test variable naming consistency (#130)
Browse files Browse the repository at this point in the history
Co-authored-by: Hogan Bobertz <bobertzh@amazon.com>
  • Loading branch information
HBobertz and Hogan Bobertz committed May 10, 2023
1 parent dd830eb commit 5b1f229
Showing 1 changed file with 20 additions and 21 deletions.
41 changes: 20 additions & 21 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use noctilucent::parser::resource::{DeletionPolicy, IntrinsicFunction};
use noctilucent::parser::resource::{ResourceAttributes, ResourceValue};
use noctilucent::primitives::WrapperF64;
use noctilucent::CloudformationParseTree;
use serde_yaml::Value;
use std::vec;

mod json;
Expand Down Expand Up @@ -46,7 +45,7 @@ macro_rules! assert_template_equal {

#[test]
fn test_parse_tree_basics() {
let a = json!({
let resource_template = json!({
"LogicalResource": {
"Type": "AWS::IAM::Role",
"Properties": {
Expand Down Expand Up @@ -74,12 +73,12 @@ fn test_parse_tree_basics() {
"Array" => ResourceValue::Array(vec![ResourceValue::String("hi".into()), ResourceValue::String("there".into())])
},
};
assert_resource_equal!("LogicalResource" => a, resource);
assert_resource_equal!("LogicalResource" => resource_template, resource);
}

#[test]
fn test_basic_parse_tree_with_condition() {
let a: Value = json!({
let resource_template = json!({
"LogicalResource": {
"Type": "AWS::IAM::Role",
"Condition": "SomeCondition",
Expand Down Expand Up @@ -108,12 +107,12 @@ fn test_basic_parse_tree_with_condition() {
"Array" => ResourceValue::Array(vec![ResourceValue::String("hi".into()), ResourceValue::String("there".into())])
},
};
assert_resource_equal!("LogicalResource" => a, resource);
assert_resource_equal!("LogicalResource" => resource_template, resource);
}

#[test]
fn test_basic_parse_tree_with_metadata() {
let a: Value = json!({
let resource_template = json!({
"LogicalResource": {
"Type": "AWS::IAM::Role",
"Metadata": {
Expand Down Expand Up @@ -146,12 +145,12 @@ fn test_basic_parse_tree_with_metadata() {
"Array" => ResourceValue::Array(vec![ResourceValue::String("hi".into()), ResourceValue::String("there".into())])
},
};
assert_resource_equal!("LogicalResource" => a, resource);
assert_resource_equal!("LogicalResource" => resource_template, resource);
}

#[test]
fn test_parse_tree_basics_with_deletion_policy() {
let a: Value = json!({
let resource_template = json!({
"LogicalResource": {
"Type": "AWS::IAM::Role",
"DeletionPolicy": "Retain",
Expand Down Expand Up @@ -181,12 +180,12 @@ fn test_parse_tree_basics_with_deletion_policy() {
},
};

assert_resource_equal!("LogicalResource" => a, resource);
assert_resource_equal!("LogicalResource" => resource_template, resource);
}

#[test]
fn test_parse_tree_sub_str() {
let a = json!({
let resource_template = json!({
"LogicalResource": {
"Type": "AWS::IAM::Role",
"Properties": {
Expand All @@ -208,12 +207,12 @@ fn test_parse_tree_sub_str() {
"RoleName" => IntrinsicFunction::Sub{ string:"bobs-role-${AWS::Region}".into(), replaces: None }.into()
},
};
assert_resource_equal!("LogicalResource" => a, resource);
assert_resource_equal!("LogicalResource" => resource_template, resource);
}

#[test]
fn test_parse_tree_yaml_codes() {
let a = json!({
let resource_template = json!({
"LogicalResource": {
"Type": "AWS::IAM::Role",
"Properties": {
Expand All @@ -235,11 +234,11 @@ fn test_parse_tree_yaml_codes() {
"RoleName" => IntrinsicFunction::Sub{ string: "bobs-role-${AWS::Region}".into(), replaces: None }.into()
},
};
assert_resource_equal!("LogicalResource" => a, resource);
assert_resource_equal!("LogicalResource" => resource_template, resource);
}
#[test]
fn test_parse_get_attr_shorthand() {
let a = json!({
let resource_template = json!({
"LogicalResource": {
"Type": "AWS::IAM::Role",
"Properties": {
Expand All @@ -261,12 +260,12 @@ fn test_parse_get_attr_shorthand() {
"RoleName" => IntrinsicFunction::GetAtt{logical_name:"Foo".into(), attribute_name:"Bar".into()}.into()
},
};
assert_resource_equal!("LogicalResource" => a, resource);
assert_resource_equal!("LogicalResource" => resource_template, resource);
}

#[test]
fn test_parse_tree_sub_list() {
let a = json!({
let resource_template = json!({
"LogicalResource": {
"Type": "AWS::IAM::Role",
"Properties": {
Expand Down Expand Up @@ -300,7 +299,7 @@ fn test_parse_tree_sub_list() {
}.into()
},
};
assert_resource_equal!("LogicalResource" => a, resource);
assert_resource_equal!("LogicalResource" => resource_template, resource);
}

#[test]
Expand Down Expand Up @@ -418,7 +417,7 @@ fn test_parse_simple_json_template() {

#[test]
fn test_parse_tree_with_fnjoin() {
let a = json!({
let resource_template = json!({
"MyBucket": {
"Type": "AWS::S3::Bucket",
"Properties": {
Expand Down Expand Up @@ -453,7 +452,7 @@ fn test_parse_tree_with_fnjoin() {
}.into()
},
};
assert_resource_equal!("MyBucket" => a, resource);
assert_resource_equal!("MyBucket" => resource_template, resource);
}

#[test]
Expand Down Expand Up @@ -559,7 +558,7 @@ fn test_parse_tree_with_fnfindinmap() {

#[test]
fn test_parse_tree_resource_with_floats() {
let a = json!({
let resource_template = json!({
"Alarm": {
"Type": "AWS::CloudWatch::Alarm",
"Properties": {
Expand Down Expand Up @@ -597,7 +596,7 @@ fn test_parse_tree_resource_with_floats() {
"Threshold" => ResourceValue::Double(WrapperF64::new(3.5))
},
};
assert_resource_equal!("Alarm" => a, resource);
assert_resource_equal!("Alarm" => resource_template, resource);
}

#[test]
Expand Down

0 comments on commit 5b1f229

Please sign in to comment.