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: make noctilucent more testable #109

Merged
merged 3 commits into from
Apr 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/parser/lookup_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use serde_yaml::{Mapping, Value};
use std::collections::HashMap;
use std::fmt::{Display, Formatter};

#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub struct MappingsParseTree {
pub mappings: HashMap<String, MappingParseTree>,
}
Expand All @@ -27,7 +27,7 @@ impl MappingsParseTree {
}
}

#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub struct MappingParseTree {
pub mappings: HashMap<String, HashMap<String, MappingInnerValue>>,
}
Expand Down
4 changes: 2 additions & 2 deletions src/parser/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{ResourceValue, TransmuteError};
use serde_yaml::Mapping;
use std::collections::HashMap;

#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub struct OutputsParseTree {
pub outputs: HashMap<String, Output>,
}
Expand All @@ -20,7 +20,7 @@ impl OutputsParseTree {
}
}

#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub struct Output {
// This is the top level name, also stored in the hash
pub logical_name: String,
Expand Down
4 changes: 2 additions & 2 deletions src/parser/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use serde_yaml::{Mapping, Value};
use std::collections::HashMap;

// template anatomy can be found here: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-anatomy.html
#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub struct Parameters {
pub params: HashMap<String, Parameter>,
}
Expand All @@ -20,7 +20,7 @@ impl Parameters {
}
}

#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub struct Parameter {
// This is the top level name, also stored in the hash
pub logical_name: String,
Expand Down
8 changes: 8 additions & 0 deletions tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,14 @@ fn assert_resource_equal(val: Value, resource: ResourceParseTree) {

fn assert_template_equal(val: Value, cfn_tree: CloudformationParseTree) {
let cfn_template = CloudformationParseTree::build(&val).unwrap();
assert_eq!(cfn_template.parameters.params, cfn_tree.parameters.params);
assert_eq!(cfn_template.mappings.mappings, cfn_tree.mappings.mappings);
assert_eq!(cfn_template.outputs.outputs, cfn_tree.outputs.outputs);
assert_eq!(cfn_template.logical_lookup, cfn_tree.logical_lookup);
assert_eq!(
cfn_template.conditions.conditions,
cfn_tree.conditions.conditions
);
assert_eq!(
cfn_template.resources.resources,
cfn_tree.resources.resources
Expand Down