|
|
@ -43,3 +43,30 @@ pub fn build(config: Config) -> Router {
|
|
|
|
.to(raw::get);
|
|
|
|
.to(raw::get);
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
|
|
|
|
mod tests {
|
|
|
|
|
|
|
|
use super::*;
|
|
|
|
|
|
|
|
use gotham::test::TestServer;
|
|
|
|
|
|
|
|
use hyper::StatusCode;
|
|
|
|
|
|
|
|
use crate::config::Config;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn setup() -> (Config, TestServer) {
|
|
|
|
|
|
|
|
let config: Config = Default::default();
|
|
|
|
|
|
|
|
let test_server = TestServer::new(build(config.clone())).unwrap();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(config, test_server)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
|
|
|
fn get_index() {
|
|
|
|
|
|
|
|
let (config, test_server) = setup();
|
|
|
|
|
|
|
|
let res = test_server
|
|
|
|
|
|
|
|
.client()
|
|
|
|
|
|
|
|
.get(config.url)
|
|
|
|
|
|
|
|
.perform()
|
|
|
|
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
assert_eq!(res.status(), StatusCode::OK);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|