From cfec11d66ea0e9c76da6fd29cd6d3ca8f14ff2b0 Mon Sep 17 00:00:00 2001 From: Eric Swanson Date: Mon, 11 Mar 2024 13:36:04 -0700 Subject: [PATCH] first test is pointless; add null value --- ic-agent/src/agent/status.rs | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/ic-agent/src/agent/status.rs b/ic-agent/src/agent/status.rs index 6f762e55..9838501e 100644 --- a/ic-agent/src/agent/status.rs +++ b/ic-agent/src/agent/status.rs @@ -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 = BTreeMap::new(); @@ -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), @@ -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); }