diff options
author | Aleksey Kladov <[email protected]> | 2018-09-02 10:34:06 +0100 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-09-02 10:34:06 +0100 |
commit | 7fad13de73ded5b8a332c5f50c18671d612bd1e3 (patch) | |
tree | 6179708a92b8fbaa8d5fdfa13b2db1f310836bd9 /crates/server/tests/heavy_tests/support.rs | |
parent | d7524556375f2b37e61fe85f17c0e4940e9e4d40 (diff) |
store messages in tests
Diffstat (limited to 'crates/server/tests/heavy_tests/support.rs')
-rw-r--r-- | crates/server/tests/heavy_tests/support.rs | 13 |
1 files changed, 11 insertions, 2 deletions
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 @@ | |||
1 | use std::{ | 1 | use std::{ |
2 | fs, | 2 | fs, |
3 | thread, | 3 | thread, |
4 | cell::Cell, | 4 | cell::{Cell, RefCell}, |
5 | path::PathBuf, | 5 | path::PathBuf, |
6 | }; | 6 | }; |
7 | 7 | ||
@@ -56,6 +56,7 @@ pub fn project(fixture: &str) -> Server { | |||
56 | 56 | ||
57 | pub struct Server { | 57 | pub struct Server { |
58 | req_id: Cell<u64>, | 58 | req_id: Cell<u64>, |
59 | messages: RefCell<Vec<RawMessage>>, | ||
59 | dir: TempDir, | 60 | dir: TempDir, |
60 | sender: Option<Sender<RawMessage>>, | 61 | sender: Option<Sender<RawMessage>>, |
61 | receiver: Receiver<RawMessage>, | 62 | receiver: Receiver<RawMessage>, |
@@ -71,6 +72,7 @@ impl Server { | |||
71 | let res = Server { | 72 | let res = Server { |
72 | req_id: Cell::new(1), | 73 | req_id: Cell::new(1), |
73 | dir, | 74 | dir, |
75 | messages: Default::default(), | ||
74 | sender: Some(client_sender), | 76 | sender: Some(client_sender), |
75 | receiver: client_receiver, | 77 | receiver: client_receiver, |
76 | server: Some(server), | 78 | server: Some(server), |
@@ -129,7 +131,7 @@ impl Server { | |||
129 | .unwrap() | 131 | .unwrap() |
130 | .send(RawMessage::Request(r)); | 132 | .send(RawMessage::Request(r)); |
131 | 133 | ||
132 | while let Some(msg) = self.receiver.recv() { | 134 | while let Some(msg) = self.recv() { |
133 | match msg { | 135 | match msg { |
134 | RawMessage::Request(req) => panic!("unexpected request: {:?}", req), | 136 | RawMessage::Request(req) => panic!("unexpected request: {:?}", req), |
135 | RawMessage::Notification(_) => (), | 137 | RawMessage::Notification(_) => (), |
@@ -144,6 +146,13 @@ impl Server { | |||
144 | } | 146 | } |
145 | panic!("no response"); | 147 | panic!("no response"); |
146 | } | 148 | } |
149 | fn recv(&self) -> Option<RawMessage> { | ||
150 | self.receiver.recv() | ||
151 | .map(|msg| { | ||
152 | self.messages.borrow_mut().push(msg.clone()); | ||
153 | msg | ||
154 | }) | ||
155 | } | ||
147 | fn send_notification(&self, not: RawNotification) { | 156 | fn send_notification(&self, not: RawNotification) { |
148 | 157 | ||
149 | self.sender.as_ref() | 158 | self.sender.as_ref() |