From 7fad13de73ded5b8a332c5f50c18671d612bd1e3 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 2 Sep 2018 12:34:06 +0300 Subject: store messages in tests --- crates/server/tests/heavy_tests/support.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'crates/server/tests/heavy_tests') diff --git a/crates/server/tests/heavy_tests/support.rs b/crates/server/tests/heavy_tests/support.rs index 113ef4c54..36ca56af3 100644 --- a/crates/server/tests/heavy_tests/support.rs +++ b/crates/server/tests/heavy_tests/support.rs @@ -1,7 +1,7 @@ use std::{ fs, thread, - cell::Cell, + cell::{Cell, RefCell}, path::PathBuf, }; @@ -56,6 +56,7 @@ pub fn project(fixture: &str) -> Server { pub struct Server { req_id: Cell, + messages: RefCell>, dir: TempDir, sender: Option>, receiver: Receiver, @@ -71,6 +72,7 @@ impl Server { let res = Server { req_id: Cell::new(1), dir, + messages: Default::default(), sender: Some(client_sender), receiver: client_receiver, server: Some(server), @@ -129,7 +131,7 @@ impl Server { .unwrap() .send(RawMessage::Request(r)); - while let Some(msg) = self.receiver.recv() { + while let Some(msg) = self.recv() { match msg { RawMessage::Request(req) => panic!("unexpected request: {:?}", req), RawMessage::Notification(_) => (), @@ -144,6 +146,13 @@ impl Server { } panic!("no response"); } + fn recv(&self) -> Option { + self.receiver.recv() + .map(|msg| { + self.messages.borrow_mut().push(msg.clone()); + msg + }) + } fn send_notification(&self, not: RawNotification) { self.sender.as_ref() -- cgit v1.2.3