Skip to content

Commit ff11098

Browse files
committed
Fix findings
1 parent fba5af4 commit ff11098

File tree

2 files changed

+10
-33
lines changed

2 files changed

+10
-33
lines changed

src/ankaios.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3188,7 +3188,7 @@ mod tests {
31883188
response_sender.send(response).await.unwrap();
31893189

31903190
// Get the agents
3191-
let ret_agents = method_handle.await.unwrap().unwrap();
3191+
let ret_agent_attributes = method_handle.await.unwrap().unwrap();
31923192

31933193
let expected_agent_attributes = AgentAttributes {
31943194
tags: HashMap::from([("tag_key".to_owned(), "tag_value".to_owned())]),
@@ -3198,7 +3198,7 @@ mod tests {
31983198
]),
31993199
};
32003200

3201-
assert_eq!(ret_agents, expected_agent_attributes);
3201+
assert_eq!(ret_agent_attributes, expected_agent_attributes);
32023202
}
32033203

32043204
#[tokio::test]

src/components/complete_state.rs

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -111,23 +111,6 @@ pub struct CompleteState {
111111
/// Struct containing the attributes of an agent of the [Ankaios] system.
112112
///
113113
/// [Ankaios]: https://eclipse-ankaios.github.io/ankaios
114-
///
115-
/// # Examples
116-
///
117-
/// ## Get the attributes of an agent:
118-
///
119-
/// ```rust
120-
/// # use ankaios_sdk::AgentAttributes;
121-
/// # use std::collections::HashMap;
122-
/// #
123-
/// # let agent_attributes = AgentAttributes {
124-
/// # tags: HashMap::new(),
125-
/// # status: HashMap::new(),
126-
/// # };
127-
/// #
128-
/// let tags = &agent_attributes.tags;
129-
/// let status = &agent_attributes.status;
130-
/// ```
131114
#[derive(Debug, Clone, PartialEq)]
132115
pub struct AgentAttributes {
133116
/// A map of custom tags as key-value pairs.
@@ -404,22 +387,16 @@ impl CompleteState {
404387
) {
405388
let agent_name_str = agent_name.into();
406389

407-
if self.complete_state.agents.is_none() {
408-
self.complete_state.agents = Some(ank_base::AgentMap {
409-
agents: HashMap::new(),
410-
});
411-
}
412-
413-
if let Some(agent_map) = self.complete_state.agents.as_mut() {
414-
let agent_attributes = agent_map.agents.entry(agent_name_str).or_insert_with(|| {
415-
ank_base::AgentAttributes {
390+
let agent_map = self.complete_state.agents.get_or_insert_default();
391+
let agent_attributes =
392+
agent_map
393+
.agents
394+
.entry(agent_name_str)
395+
.or_insert_with(|| ank_base::AgentAttributes {
416396
status: None,
417397
tags: None,
418-
}
419-
});
420-
421-
agent_attributes.tags = Some(ank_base::Tags { tags });
422-
}
398+
});
399+
agent_attributes.tags = Some(ank_base::Tags { tags });
423400
}
424401

425402
/// Sets the configurations of the `CompleteState`.

0 commit comments

Comments
 (0)