Skip to content

Commit

Permalink
first test is pointless; add null value
Browse files Browse the repository at this point in the history
  • Loading branch information
ericswanson-dfinity committed Mar 11, 2024
1 parent e9a2e73 commit cfec11d
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions ic-agent/src/agent/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,6 @@ impl Serialize for Status {

#[test]
fn can_serialize_status_as_json() {
let status = Status {
impl_version: None,
replica_health_status: None,
root_key: None,
values: BTreeMap::new(),
};
let expected_json =
r#"{"impl_version":null,"replica_health_status":null,"root_key":null,"values":{}}"#;
let actual_json = serde_json::to_string(&status).expect("Failed to serialize as JSON");
assert_eq!(expected_json, actual_json);
}

#[test]
fn can_serialize_status_as_json_with_non_null() {
use serde_cbor::value::Value::Text;

let mut map: BTreeMap<serde_cbor::value::Value, serde_cbor::value::Value> = BTreeMap::new();
Expand All @@ -131,6 +117,7 @@ fn can_serialize_status_as_json_with_non_null() {
Text("root_key".to_string()),
serde_cbor::value::Value::Bytes(vec![1, 2, 3, 4]),
);
map.insert(Text("nully".to_string()), serde_cbor::value::Value::Null);
map.insert(
Text("truthy".to_string()),
serde_cbor::value::Value::Bool(true),
Expand All @@ -143,7 +130,7 @@ fn can_serialize_status_as_json_with_non_null() {
);
let cbor = serde_cbor::Value::Map(map);
let status = Status::try_from(&cbor).expect("Failed to convert from cbor");
let expected_json = r#"{"arbitrary":null,"certified_height":654275,"impl_version":"0.19.2","replica_health_status":"healthy","root_key":[1,2,3,4],"submap":{"foo":"bar"},"truthy":true}"#;
let expected_json = r#"{"arbitrary":null,"certified_height":654275,"impl_version":"0.19.2","nully":null,"replica_health_status":"healthy","root_key":[1,2,3,4],"submap":{"foo":"bar"},"truthy":true}"#;
let actual_json = serde_json::to_string(&status).expect("Failed to serialize as JSON");
assert_eq!(expected_json, actual_json);
}
Expand Down

0 comments on commit cfec11d

Please sign in to comment.