Gave control to documents service.
This commit is contained in:
@ -1,4 +1,7 @@
|
||||
use crate::{ErrorType, queue::{Message, MsgType, Queue}};
|
||||
use crate::{
|
||||
queue::{Message, MsgType, Queue},
|
||||
ErrorType,
|
||||
};
|
||||
use std::{
|
||||
sync::mpsc::{channel, Receiver},
|
||||
thread::spawn,
|
||||
@ -40,7 +43,7 @@ impl Document {
|
||||
output.add_data("error_type", ErrorType::DocumentNotFound);
|
||||
output
|
||||
}
|
||||
},
|
||||
}
|
||||
None => msg.reply(MsgType::Document),
|
||||
};
|
||||
reply.add_data("doc", "Something goes hwew");
|
||||
@ -91,12 +94,12 @@ pub mod documents {
|
||||
let reply = rx.recv_timeout(TIMEOUT).unwrap();
|
||||
assert_eq!(reply.get_id(), msg.get_id());
|
||||
match reply.get_msg_type() {
|
||||
MsgType::Error => {},
|
||||
MsgType::Error => {}
|
||||
_ => unreachable!("got {:?}: shoud have been error", reply.get_msg_type()),
|
||||
}
|
||||
match reply.get_data("error_type") {
|
||||
Some(err) => match err.to_error_type().unwrap() {
|
||||
ErrorType::DocumentNotFound => {},
|
||||
ErrorType::DocumentNotFound => {}
|
||||
_ => unreachable!("got {:?}: should have been document not found'", err),
|
||||
},
|
||||
None => unreachable!("should contain error type"),
|
||||
@ -112,8 +115,11 @@ pub mod documents {
|
||||
queue.send(msg);
|
||||
let reply = rx.recv().unwrap();
|
||||
match reply.get_msg_type() {
|
||||
MsgType::Document => {},
|
||||
_ => unreachable!("Got '{:?}': should have been a document", reply.get_msg_type()),
|
||||
MsgType::Document => {}
|
||||
_ => unreachable!(
|
||||
"Got '{:?}': should have been a document",
|
||||
reply.get_msg_type()
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user