override config only ones
This commit is contained in:
parent
dda7abfa23
commit
6c9eb99d80
@ -1,5 +1,4 @@
|
|||||||
use std::{
|
use std::{
|
||||||
process,
|
|
||||||
thread::{self, sleep},
|
thread::{self, sleep},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
@ -17,8 +16,6 @@ fn timed_kill(sec: u64, mut proc_ctl: ProcessControl) {
|
|||||||
sleep(Duration::from_secs(sec));
|
sleep(Duration::from_secs(sec));
|
||||||
|
|
||||||
proc_ctl.kill_all();
|
proc_ctl.kill_all();
|
||||||
|
|
||||||
process::exit(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -49,30 +46,30 @@ fn playlist_change_at_midnight() {
|
|||||||
player(play_control, playout_stat, proc_control);
|
player(play_control, playout_stat, proc_control);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
// #[test]
|
||||||
#[ignore]
|
// #[ignore]
|
||||||
fn playlist_change_at_six() {
|
// fn playlist_change_at_six() {
|
||||||
let config = TestConfig {
|
// let config = TestConfig {
|
||||||
mode: "playlist".into(),
|
// mode: "playlist".into(),
|
||||||
start: "06:00:00".into(),
|
// start: "06:00:00".into(),
|
||||||
length: "24:00:00".into(),
|
// length: "24:00:00".into(),
|
||||||
log_to_file: false,
|
// log_to_file: false,
|
||||||
mail_recipient: "".into(),
|
// mail_recipient: "".into(),
|
||||||
};
|
// };
|
||||||
|
|
||||||
init_config(Some(config));
|
// init_config(Some(config));
|
||||||
|
|
||||||
let play_control = PlayerControl::new();
|
// let play_control = PlayerControl::new();
|
||||||
let playout_stat = PlayoutStatus::new();
|
// let playout_stat = PlayoutStatus::new();
|
||||||
let proc_control = ProcessControl::new();
|
// let proc_control = ProcessControl::new();
|
||||||
let proc_ctl = proc_control.clone();
|
// let proc_ctl = proc_control.clone();
|
||||||
|
|
||||||
let logging = init_logging();
|
// let logging = init_logging();
|
||||||
CombinedLogger::init(logging).unwrap();
|
// CombinedLogger::init(logging).unwrap();
|
||||||
|
|
||||||
mock_time::set_mock_time("2022-05-09T05:59:45");
|
// mock_time::set_mock_time("2022-05-09T05:59:45");
|
||||||
|
|
||||||
thread::spawn(move || timed_kill(30, proc_ctl));
|
// thread::spawn(move || timed_kill(30, proc_ctl));
|
||||||
|
|
||||||
player(play_control, playout_stat, proc_control);
|
// player(play_control, playout_stat, proc_control);
|
||||||
}
|
// }
|
||||||
|
@ -35,3 +35,20 @@ fn get_date_tomorrow() {
|
|||||||
|
|
||||||
assert_eq!("2022-05-21".to_string(), date);
|
assert_eq!("2022-05-21".to_string(), date);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_delta() {
|
||||||
|
let config = TestConfig {
|
||||||
|
mode: "playlist".into(),
|
||||||
|
start: "00:00:00".into(),
|
||||||
|
length: "24:00:00".into(),
|
||||||
|
log_to_file: false,
|
||||||
|
mail_recipient: "".into(),
|
||||||
|
};
|
||||||
|
|
||||||
|
init_config(Some(config));
|
||||||
|
mock_time::set_mock_time("2022-05-09T23:59:59");
|
||||||
|
let (delta, _) = get_delta(&86401.0);
|
||||||
|
|
||||||
|
assert!(delta < 2.0);
|
||||||
|
}
|
||||||
|
@ -223,6 +223,9 @@ impl GlobalConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(log_path) = args.log {
|
if let Some(log_path) = args.log {
|
||||||
|
if Path::new(&log_path).is_dir() {
|
||||||
|
config.logging.log_to_file = true;
|
||||||
|
}
|
||||||
config.logging.log_path = log_path;
|
config.logging.log_path = log_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,7 +272,7 @@ impl GlobalConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn global() -> &'static GlobalConfig {
|
pub fn global() -> &'static GlobalConfig {
|
||||||
INSTANCE.get().expect("Config is not initialized")
|
INSTANCE.get_or_init(GlobalConfig::new)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user