aboutsummaryrefslogtreecommitdiff
path: root/crates/server/tests/heavy_tests/support.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/server/tests/heavy_tests/support.rs')
-rw-r--r--crates/server/tests/heavy_tests/support.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/crates/server/tests/heavy_tests/support.rs b/crates/server/tests/heavy_tests/support.rs
index 76cbd56ea..38a9e6c76 100644
--- a/crates/server/tests/heavy_tests/support.rs
+++ b/crates/server/tests/heavy_tests/support.rs
@@ -134,7 +134,7 @@ impl Server {
134 { 134 {
135 let expected = expected.replace("$PROJECT_ROOT$", &self.dir.path().display().to_string()); 135 let expected = expected.replace("$PROJECT_ROOT$", &self.dir.path().display().to_string());
136 let expected: Value = from_str(&expected).unwrap(); 136 let expected: Value = from_str(&expected).unwrap();
137 let actual = self.wait_for_notification(N::METHOD); 137 let actual = self.wait_for_notification::<N>();
138 assert_eq!( 138 assert_eq!(
139 expected, actual, 139 expected, actual,
140 "Expected:\n{}\n\ 140 "Expected:\n{}\n\
@@ -150,6 +150,11 @@ impl Server {
150 R::Params: Serialize, 150 R::Params: Serialize,
151 { 151 {
152 let r = RawRequest::new::<R>(id, &params); 152 let r = RawRequest::new::<R>(id, &params);
153 self.send_request_(r)
154 }
155 fn send_request_(&self, r: RawRequest) -> Value
156 {
157 let id = r.id;
153 self.sender.as_ref() 158 self.sender.as_ref()
154 .unwrap() 159 .unwrap()
155 .send(RawMessage::Request(r)); 160 .send(RawMessage::Request(r));
@@ -168,7 +173,10 @@ impl Server {
168 } 173 }
169 panic!("no response"); 174 panic!("no response");
170 } 175 }
171 fn wait_for_notification(&self, method: &str) -> Value { 176 pub fn wait_for_notification<N: Notification>(&self) -> Value {
177 self.wait_for_notification_(N::METHOD)
178 }
179 fn wait_for_notification_(&self, method: &str) -> Value {
172 let f = |msg: &RawMessage| match msg { 180 let f = |msg: &RawMessage| match msg {
173 RawMessage::Notification(n) if n.method == method => { 181 RawMessage::Notification(n) if n.method == method => {
174 Some(n.params.clone()) 182 Some(n.params.clone())
@@ -215,7 +223,6 @@ impl Drop for Server {
215 drop(msg); 223 drop(msg);
216 } 224 }
217 } 225 }
218 eprintln!("joining server");
219 self.server.take() 226 self.server.take()
220 .unwrap() 227 .unwrap()
221 .join().unwrap().unwrap(); 228 .join().unwrap().unwrap();