From 405a7f0391f1112a17eb26fc2a5f531059e9e646 Mon Sep 17 00:00:00 2001 From: Hogan Bobertz Date: Thu, 13 Apr 2023 13:35:40 -0400 Subject: [PATCH] add conditional test --- .gitignore | 1 + tests/tests.rs | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/.gitignore b/.gitignore index eb1f8ce0..32e5e394 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ Cargo.lock # These are backup files generated by rustfmt **/*.rs.bk +.vscode/ \ No newline at end of file diff --git a/tests/tests.rs b/tests/tests.rs index 069ffae8..4da39b40 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -48,6 +48,41 @@ fn test_parse_tree_basics() { assert_resource_equal(a, resource); } +#[test] +fn test_basic_parse_tree_with_condition() { + let a: Value = serde_json::json!({ + "LogicalResource": { + "Type": "AWS::IAM::Role", + "Condition": "SomeCondition", + "Properties": { + "RoleName": "bob", + "AssumeTime": 20, + "Bool": true, + "NotExistent": {"Ref": "AWS::NoValue"}, + "Array": ["hi", "there"] + } + } + }); + + let resource = ResourceParseTree { + name: "LogicalResource".into(), + condition: Option::Some("SomeCondition".into()), + metadata: Option::None, + update_policy: Option::None, + deletion_policy: Option::None, + dependencies: vec![], + resource_type: "AWS::IAM::Role".into(), + properties: map! { + "RoleName" => ResourceValue::String("bob".into()), + "AssumeTime" => ResourceValue::Number(20), + "Bool" => ResourceValue::Bool(true), + "NotExistent" => ResourceValue::Null, + "Array" => ResourceValue::Array(vec![ResourceValue::String("hi".into()), ResourceValue::String("there".into())]) + }, + }; + assert_resource_equal(a, resource); +} + #[test] fn test_parse_tree_sub_str() { let a = serde_json::json!({