Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ericswanson-dfinity committed Mar 11, 2024
1 parent 66f7758 commit e9a2e73
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions ic-agent/src/agent/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,20 +119,31 @@ fn can_serialize_status_as_json_with_non_null() {
Text("replica_health_status".to_string()),
Text("healthy".to_string()),
);
map.insert(Text("certified_height".to_string()), serde_cbor::value::Value::Integer(654275));
map.insert(
Text("certified_height".to_string()),
serde_cbor::value::Value::Integer(654275),
);
map.insert(
Text("arbitrary".to_string()),
serde_cbor::value::Value::Null,
);
map.insert(Text("root_key".to_string()), serde_cbor::value::Value::Bytes(vec![1, 2, 3, 4]));
map.insert(Text("truthy".to_string()), serde_cbor::value::Value::Bool(true));
map.insert(
Text("root_key".to_string()),
serde_cbor::value::Value::Bytes(vec![1, 2, 3, 4]),
);
map.insert(
Text("truthy".to_string()),
serde_cbor::value::Value::Bool(true),
);
let mut submap = BTreeMap::new();
submap.insert(Text("foo".to_string()), Text("bar".to_string()));
map.insert(Text("submap".to_string()), serde_cbor::value::Value::Map(submap));
map.insert(
Text("submap".to_string()),
serde_cbor::value::Value::Map(submap),
);
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","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 e9a2e73

Please sign in to comment.