From 06e42ea8076eaef72484d8fda1c095a1eaceba03 Mon Sep 17 00:00:00 2001 From: rasul Date: Sun, 2 Feb 2020 12:29:30 -0600 Subject: [PATCH] add a test --- src/routes.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/routes.rs b/src/routes.rs index c098466..eda4082 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -43,3 +43,30 @@ pub fn build(config: Config) -> Router { .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); + } +}