1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-24 00:21:08 +01:00

proper stop for test_ws_stopped test

This commit is contained in:
Nikolay Kim 2018-10-01 21:30:00 -07:00
parent 84edc57fd9
commit 7c78797d9b

View File

@ -361,7 +361,7 @@ struct WsStopped(Arc<AtomicUsize>);
impl Actor for WsStopped { impl Actor for WsStopped {
type Context = ws::WebsocketContext<Self>; type Context = ws::WebsocketContext<Self>;
fn stopped(&mut self, ctx: &mut Self::Context) { fn stopped(&mut self, _: &mut Self::Context) {
self.0.fetch_add(1, Ordering::Relaxed); self.0.fetch_add(1, Ordering::Relaxed);
} }
} }
@ -387,12 +387,10 @@ fn test_ws_stopped() {
app.handler(move |req| ws::start(req, WsStopped(num4.clone()))) app.handler(move |req| ws::start(req, WsStopped(num4.clone())))
}); });
let (reader, mut writer) = srv.ws().unwrap(); let (reader, mut writer) = srv.ws().unwrap();
writer.text("text"); writer.text("text");
let (item, reader) = srv.execute(reader.into_future()).unwrap(); let (item, _) = srv.execute(reader.into_future()).unwrap();
assert_eq!(item, Some(ws::Message::Text("text".to_owned()))); assert_eq!(item, Some(ws::Message::Text("text".to_owned())));
}); }).join();
thread::sleep(time::Duration::from_secs(3));
assert_eq!(num.load(Ordering::Relaxed), 1); assert_eq!(num.load(Ordering::Relaxed), 1);
} }