Reattached document service.
This commit is contained in:
parent
0ab0b59f4c
commit
38af08eb14
@ -155,4 +155,19 @@ mod clients {
|
|||||||
assert_eq!(result.get_id(), expected.get_id());
|
assert_eq!(result.get_id(), expected.get_id());
|
||||||
assert_eq!(result.get_msg_type(), expected.get_msg_type());
|
assert_eq!(result.get_msg_type(), expected.get_msg_type());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn document_return() {
|
||||||
|
let queue = Queue::new();
|
||||||
|
let (queue_tx, queue_rx) = channel();
|
||||||
|
queue.add(queue_tx, [MsgType::DocumentRequest].to_vec());
|
||||||
|
let chan = Client::start(queue.clone());
|
||||||
|
let chan_rx = chan.send(Message::new(MsgType::DocumentRequest));
|
||||||
|
let msg = queue_rx.recv_timeout(TIMEOUT).unwrap();
|
||||||
|
let expected = msg.reply(MsgType::Document);
|
||||||
|
queue.send(expected.clone()).unwrap();
|
||||||
|
let result = chan_rx.recv_timeout(TIMEOUT).unwrap();
|
||||||
|
assert_eq!(result.get_id(), expected.get_id());
|
||||||
|
assert_eq!(result.get_msg_type(), expected.get_msg_type());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,4 +42,12 @@ impl MoreThanText {
|
|||||||
let reply = rx.recv().unwrap();
|
let reply = rx.recv().unwrap();
|
||||||
reply.get_data("sess_id").unwrap().to_uuid().unwrap()
|
reply.get_data("sess_id").unwrap().to_uuid().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_document(&self, sess_id: Uuid) -> String {
|
||||||
|
let mut msg = Message::new(MsgType::DocumentRequest);
|
||||||
|
msg.add_data("sess_id", sess_id);
|
||||||
|
let rx = self.client_channel.send(msg);
|
||||||
|
let reply = rx.recv().unwrap();
|
||||||
|
reply.get_data("doc").unwrap().to_string()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,8 +80,13 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn mtt_conn(_sess_id: SessionID, _state: State<MoreThanText>) -> impl IntoResponse {
|
async fn mtt_conn(sess_id: SessionID, state: State<MoreThanText>) -> impl IntoResponse {
|
||||||
("something".to_string(),)
|
let (tx, mut rx) = channel(1);
|
||||||
|
spawn(async move {
|
||||||
|
tx.send(state.get_document(sess_id.0)).await.unwrap();
|
||||||
|
});
|
||||||
|
let content = rx.recv().await.unwrap();
|
||||||
|
content
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user