From bb5f25dc99180e10b5ab3fd81b4e2f539a70665e Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Thu, 25 Feb 2021 00:20:52 +0000 Subject: [PATCH] tests: refactor connect_player Signed-off-by: Ian Jackson --- apitest.rs | 1 + apitest/at-otter.rs | 13 ++++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/apitest.rs b/apitest.rs index bbf4ec3f..b62c96c6 100644 --- a/apitest.rs +++ b/apitest.rs @@ -42,6 +42,7 @@ pub use std::iter; pub use std::mem; pub use std::net::TcpStream; pub use std::ops::{Deref, DerefMut}; +pub use std::os::unix::net::UnixStream; pub use std::os::unix::process::CommandExt; pub use std::os::unix::fs::DirBuilderExt; pub use std::os::linux::fs::MetadataExt; // todo why linux for st_mode?? diff --git a/apitest/at-otter.rs b/apitest/at-otter.rs index 2f370e5c..c4f18bce 100644 --- a/apitest/at-otter.rs +++ b/apitest/at-otter.rs @@ -21,11 +21,14 @@ struct Player { url: String, } +struct Session { + pub dom: scraper::html::Html, + pub updates: UnixStream, +} + impl Ctx { #[throws(AE)] - fn connect_player(&self, player: &Player) - -> (scraper::html::Html, impl std::io::Read) - { + fn connect_player(&self, player: &Player) -> Session { let client = reqwest::blocking::Client::new(); let resp = client.get(&player.url).send()?; @@ -70,14 +73,14 @@ impl Ctx { .subst("@url@/_/updates?ctoken=@ctoken@&gen=@gen@")? ).send()?; - let (mut writer, reader) = std::os::unix::net::UnixStream::pair()?; + let (mut writer, reader) = UnixStream::pair()?; thread::spawn(move ||{ eprintln!("copy_to'ing"); sse.copy_to(&mut writer).unwrap(); eprintln!("copy_to'd!"); }); - (session, reader) + Session { dom: session, updates: reader } } } -- 2.30.2