Question regarding tables::node::Table::update
#329
-
Hello, I think But it is possible that I misunderstood the intention of this |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
I personally tried this ad-hoc test, which was written according to my expectations, and it failed, which was the starting point for this question. #[test]
fn update_agents_drafts_only() {
let store: Arc<Store> = setup_store();
let kinds = vec![AgentKind::Reconverge, AgentKind::Piglet, AgentKind::Hog];
let configs1: Vec<_> = create_configs(&kinds);
let configs2 = vec![None, None, None];
let profile = Profile::default();
let agents = create_agents(123, &kinds, &configs1, &configs2);
let mut node = create_node(
456,
"test",
None,
None,
Some(profile.clone()),
agents.clone(),
);
let mut node_table = store.node_map();
let res = node_table.put(node.clone());
assert!(res.is_ok());
// update node id to the actual id in database.
node.id = res.unwrap();
node.agents.iter_mut().for_each(|a| a.node = node.id);
let id = node.id;
let old = node.clone().into();
let mut update = node.clone();
update.agents = update.agents.into_iter().map(|mut a| {
// the `draft` field of each agent
a.draft = Some("my_key=10".to_string().try_into().unwrap());
a
}).collect();
let update = update.into();
assert!(node_table.update(id, &old, &update).is_ok());
let updated = node_table.get_by_id(id).unwrap();
assert!(updated.is_some());
let (updated, invalid) = updated.unwrap();
assert!(invalid.is_empty());
assert_eq!(updated.agents, update.agents); // expected success but failed
} |
Beta Was this translation helpful? Give feedback.
-
@minshao |
Beta Was this translation helpful? Give feedback.
See #332
🙇