diff --git a/.travis.yml b/.travis.yml index 8a71b2be..daace7d7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,3 +3,4 @@ rust: - nightly script: - cargo build + - RUST_BACKTRACE=1 cargo test diff --git a/src/context.rs b/src/context.rs index 482e68e0..b295ec78 100644 --- a/src/context.rs +++ b/src/context.rs @@ -75,3 +75,36 @@ impl Context { (self.hostname.as_str(), self.http_port).to_socket_addrs() } } + +#[test] +#[allow(unused_variables)] +fn test_should_add_a_service() { + use service::{ Service, ServiceProperties }; + use iron::{Request, Response, IronResult}; + + struct ServiceStub; + + impl Service for ServiceStub { + fn get_properties(&self) -> ServiceProperties { + ServiceProperties { + id: '1'.to_string(), + name: "dummy service".to_string(), + description: "really nothing to see".to_string(), + http_url: '2'.to_string(), + ws_url: '3'.to_string() + } + } + fn start(&self) {} + fn stop(&self) {} + fn process_request(&self, req: &Request) -> IronResult { + return Ok(Response::new()); + } + } + + let service = ServiceStub; + let mut foo = Context::new(false, Some("localhost".to_owned())); + + assert_eq!(foo.services.is_empty(), true); + foo.add_service(Box::new(service)); + assert_eq!(foo.services.is_empty(), false); +}