Skip to content

Commit

Permalink
config/deser: add two new unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Tibor Benke <[email protected]>
  • Loading branch information
ihrwein committed Jan 29, 2016
1 parent a8abe81 commit d72f1aa
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/config/deser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,25 @@ mod test {
assert_eq!(&expected_actions, &context.actions);
}

#[test]
fn test_given_config_context_when_it_does_not_have_uuid_then_it_cannot_be_deserialized() {
let text = r#"{ "conditions": { "timeout": 100 }}"#;
let result = from_str::<Context>(text);
println!("{:?}", &result);
let _ = result.err().expect("Successfully deserialized a config context without an uuid key");
}

#[test]
fn test_given_config_context_when_it_contains_an_unknown_key_then_it_cannot_be_deserialized() {
let text = r#"
{"uuid": "86ca9f93-84fb-4813-b037-6526f7a585a3",
"conditions": { "timeout": 100},
"unknown": "unknown" }"#;
let result = from_str::<Context>(text);
println!("{:?}", &result);
let _ = result.err().expect("Successfully deserialized a config context with an unknown key");
}

#[test]
fn test_given_config_context_when_it_is_deserialized_and_only_the_required_fields_are_present_then_we_can_deserialize_it_successfully
() {
Expand Down

0 comments on commit d72f1aa

Please sign in to comment.