Skip to content

Instantly share code, notes, and snippets.

@sethlopezme
Last active December 28, 2016 02:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sethlopezme/19315dcf21a48d65684f849ff191db7c to your computer and use it in GitHub Desktop.
Save sethlopezme/19315dcf21a48d65684f849ff191db7c to your computer and use it in GitHub Desktop.
config/tests/common/mod.rs
#![feature(plugin)]
#![plugin(rocket_codegen)]
// use rocket::config;
use rocket::http::Method;
use rocket::testing::MockRequest;
extern crate config as lib;
#[test]
pub fn test_config(environment: &str) {
// set the environment for rocket
std::env::set_var("ROCKET_ENV", environment);
rocket::ignite().mount("/hello", routes![lib::hello]);
let mut request = MockRequest::new(Method::Get, "/hello");
let mut response = request.dispatch_with(&rocket);
assert_eq!(response.body().and_then(|b| b.into_string()),
Some("Hello, world!".to_string()));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment