Registry can now return name ids.
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1s
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1s
This commit is contained in:
parent
4d54b07276
commit
672ed93da3
@ -967,6 +967,7 @@ enum RegMsg {
|
||||
AddDocName(Vec<Name>),
|
||||
DocumentNameID(Uuid),
|
||||
Error(MTTError),
|
||||
GetNameID(Name),
|
||||
Ok,
|
||||
}
|
||||
|
||||
@ -1227,6 +1228,10 @@ impl DocRegistry {
|
||||
senders.insert(reg.get_sender_id().clone());
|
||||
reg.response(RegMsg::Ok)
|
||||
}
|
||||
RegMsg::GetNameID(name) => match self.doc_names.get_id(name) {
|
||||
Ok(id) => reg.response(RegMsg::DocumentNameID(id.clone())),
|
||||
Err(err) => reg.response(RegMsg::Error(err)),
|
||||
}
|
||||
_ => reg.response(RegMsg::Ok),
|
||||
}
|
||||
}
|
||||
@ -1504,6 +1509,35 @@ mod queues {
|
||||
tester.get_preset_id().clone(),
|
||||
RegMsg::AddDocName(names.clone()),
|
||||
);
|
||||
let msg = Message::new(NameType::None, reg_msg);
|
||||
queue.send(msg.clone()).unwrap();
|
||||
let result = tester.get_preset_rx().recv_timeout(TIMEOUT).unwrap();
|
||||
let action = result.get_action();
|
||||
let id = match action {
|
||||
MsgAction::Register(data) => match data.get_msg() {
|
||||
RegMsg::DocumentNameID(data) => data,
|
||||
_ => unreachable!("got {:?}, should have returned id", data),
|
||||
}
|
||||
_ => unreachable!("got {:?}, should have returned id", action),
|
||||
};
|
||||
for name in names.iter() {
|
||||
let reg_msg = Register::new(
|
||||
tester.get_preset_id().clone(),
|
||||
RegMsg::GetNameID(name.clone()),
|
||||
);
|
||||
let msg = Message::new(NameType::None, reg_msg);
|
||||
queue.send(msg.clone()).unwrap();
|
||||
let result = tester.get_preset_rx().recv_timeout(TIMEOUT).unwrap();
|
||||
let action = result.get_action();
|
||||
let result = match action {
|
||||
MsgAction::Register(data) => match data.get_msg() {
|
||||
RegMsg::DocumentNameID(data) => data,
|
||||
_ => unreachable!("got {:?}, should have returned id", data),
|
||||
}
|
||||
_ => unreachable!("got {:?}, should have returned id", action),
|
||||
};
|
||||
assert_eq!(result, id);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user