diff --git a/Cargo.toml b/Cargo.toml index d957f69..8996c88 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,3 +11,7 @@ url = "1.7.0" log = "0.4.1" env_logger = "0.5.6" ammonia = "1.1.0" + +# see issue #7 +#[dev-dependencies] +#iron = "0.6.0" diff --git a/src/main.rs b/src/main.rs index 9ebf559..ff465cb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,6 +7,10 @@ extern crate reqwest; extern crate robotparser; extern crate url; +// see issue #7 +//#[cfg(test)] +//extern crate iron; + use reqwest::Client; use robotparser::RobotFileParser; use url::Url; @@ -74,6 +78,7 @@ fn main_loop() { } fn _main_loop(starton: String, panic: bool) -> Vec { + // see issue #7 let client = Client::new(); let mut future_urls: Vec; let mut future_url_buffer: Vec = Vec::new(); @@ -198,3 +203,45 @@ fn _main_loop(starton: String, panic: bool) -> Vec { } } } + +#[cfg(test)] +mod tests { + // see issue #7 + //use iron::{Iron, IronResult, Headers}; + //use iron::response::Response; + //use iron::request::Request; + //use iron::status; + //use iron::middleware::Chain; + //use iron::headers::ContentType; + //use iron::mime::{Mime, TopLevel, SubLevel}; + //use iron::typemap::TypeMap; + use std; + + use ::*; + + // see issue #7 + //#[test] + //fn __main_loop() { + // fn handler(req: &mut Request) -> IronResult { + // let mut mime = Headers::new(); + // mime.set(ContentType(Mime(TopLevel::Text, SubLevel::Html, Vec::new()))); + + // Ok(Response { + // headers: mime, + // status: Some(status::Ok), + // body: Some(Box::new(match req.url.path().join("/").as_str() { + // "" => "", + // "file" => "", + // "file1" => "", + // _ => "not found" + // })), + // extensions: TypeMap::new() + // }) + // } + + // let child = std::thread::spawn(|| Iron::new(Chain::new(handler)).http("localhost:9999").unwrap()); + + // let f: Vec = Vec::new(); + // assert_eq!(_main_loop("http://localhost:9999/".to_string(), false), f); + //} +}