2020-09-03 05:41:31 +00:00
|
|
|
use rocket::config::{Config, LogLevel};
|
|
|
|
|
2020-10-22 10:27:04 +00:00
|
|
|
fn test_config(profile: &str) {
|
|
|
|
let rocket = rocket::custom(Config::figment().select(profile));
|
|
|
|
let config = rocket.config();
|
2020-09-03 05:41:31 +00:00
|
|
|
match &*profile {
|
|
|
|
"debug" => {
|
|
|
|
assert_eq!(config.address, std::net::Ipv4Addr::LOCALHOST);
|
|
|
|
assert_eq!(config.port, 8000);
|
|
|
|
assert_eq!(config.workers, 1);
|
|
|
|
assert_eq!(config.keep_alive, 0);
|
|
|
|
assert_eq!(config.log_level, LogLevel::Normal);
|
|
|
|
}
|
|
|
|
"release" => {
|
|
|
|
assert_eq!(config.address, std::net::Ipv4Addr::LOCALHOST);
|
|
|
|
assert_eq!(config.port, 8000);
|
|
|
|
assert_eq!(config.workers, 12);
|
|
|
|
assert_eq!(config.keep_alive, 5);
|
|
|
|
assert_eq!(config.log_level, LogLevel::Critical);
|
|
|
|
assert!(!config.secret_key.is_zero());
|
|
|
|
}
|
|
|
|
_ => {
|
|
|
|
panic!("Unknown profile: {}", profile);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-22 10:27:04 +00:00
|
|
|
#[test]
|
|
|
|
fn test_debug_config() {
|
|
|
|
test_config("debug")
|
2020-09-03 05:41:31 +00:00
|
|
|
}
|
|
|
|
|
2020-10-22 10:27:04 +00:00
|
|
|
#[test]
|
|
|
|
fn test_release_config() {
|
|
|
|
test_config("release")
|
2020-09-03 05:41:31 +00:00
|
|
|
}
|