Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ rust:
- nightly
script:
- cargo build
- RUST_BACKTRACE=1 cargo test
33 changes: 33 additions & 0 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Response> {
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);
}