fix tests

This commit is contained in:
Jonathan Baecker 2024-10-28 17:07:29 +01:00
parent a77287526f
commit 188f9a1712
2 changed files with 38 additions and 19 deletions

View File

@ -103,7 +103,6 @@ fn test_gen_source() {
#[ignore]
fn playlist_missing() {
let (mut config, manager) = get_config();
let manager_clone = manager.clone();
config.general.skip_validation = true;
config.mail.recipient = "".into();
@ -121,7 +120,10 @@ fn playlist_missing() {
config.output.output_filter = None;
config.output.output_cmd = Some(vec_strings!["-f", "null", "-"]);
set_mock_time(&Some("2023-02-07T23:59:45".to_string()));
manager.update_config(config);
let manager_clone = manager.clone();
set_mock_time(&Some("2023-02-07T23:59:45+01:00".to_string()));
thread::spawn(move || timed_stop(28, manager_clone));
@ -137,7 +139,6 @@ fn playlist_missing() {
#[ignore]
fn playlist_next_missing() {
let (mut config, manager) = get_config();
let manager_clone = manager.clone();
config.general.skip_validation = true;
config.mail.recipient = "".into();
@ -155,7 +156,10 @@ fn playlist_next_missing() {
config.output.output_filter = None;
config.output.output_cmd = Some(vec_strings!["-f", "null", "-"]);
set_mock_time(&Some("2023-02-09T23:59:45".to_string()));
manager.update_config(config);
let manager_clone = manager.clone();
set_mock_time(&Some("2023-02-09T23:59:45+01:00".to_string()));
thread::spawn(move || timed_stop(28, manager_clone));
@ -171,7 +175,6 @@ fn playlist_next_missing() {
#[ignore]
fn playlist_to_short() {
let (mut config, manager) = get_config();
let manager_clone = manager.clone();
config.general.skip_validation = true;
config.mail.recipient = "".into();
@ -189,7 +192,10 @@ fn playlist_to_short() {
config.output.output_filter = None;
config.output.output_cmd = Some(vec_strings!["-f", "null", "-"]);
set_mock_time(&Some("2024-01-31T05:59:40".to_string()));
manager.update_config(config);
let manager_clone = manager.clone();
set_mock_time(&Some("2024-01-31T05:59:40+01:00".to_string()));
thread::spawn(move || timed_stop(28, manager_clone));
@ -205,7 +211,6 @@ fn playlist_to_short() {
#[ignore]
fn playlist_init_after_list_end() {
let (mut config, manager) = get_config();
let manager_clone = manager.clone();
config.general.skip_validation = true;
config.mail.recipient = "".into();
@ -223,7 +228,10 @@ fn playlist_init_after_list_end() {
config.output.output_filter = None;
config.output.output_cmd = Some(vec_strings!["-f", "null", "-"]);
set_mock_time(&Some("2024-01-31T05:59:47".to_string()));
manager.update_config(config);
let manager_clone = manager.clone();
set_mock_time(&Some("2024-01-31T05:59:47+01:00".to_string()));
thread::spawn(move || timed_stop(28, manager_clone));
@ -239,7 +247,6 @@ fn playlist_init_after_list_end() {
#[ignore]
fn playlist_change_at_midnight() {
let (mut config, manager) = get_config();
let manager_clone = manager.clone();
config.general.skip_validation = true;
config.mail.recipient = "".into();
@ -257,7 +264,10 @@ fn playlist_change_at_midnight() {
config.output.output_filter = None;
config.output.output_cmd = Some(vec_strings!["-f", "null", "-"]);
set_mock_time(&Some("2023-02-08T23:59:45".to_string()));
manager.update_config(config);
let manager_clone = manager.clone();
set_mock_time(&Some("2023-02-08T23:59:45+01:00".to_string()));
thread::spawn(move || timed_stop(28, manager_clone));
@ -273,7 +283,6 @@ fn playlist_change_at_midnight() {
#[ignore]
fn playlist_change_before_midnight() {
let (mut config, manager) = get_config();
let manager_clone = manager.clone();
config.general.skip_validation = true;
config.mail.recipient = "".into();
@ -291,7 +300,10 @@ fn playlist_change_before_midnight() {
config.output.output_filter = None;
config.output.output_cmd = Some(vec_strings!["-f", "null", "-"]);
set_mock_time(&Some("2023-02-08T23:59:30".to_string()));
manager.update_config(config);
let manager_clone = manager.clone();
set_mock_time(&Some("2023-02-08T23:59:30+01:00".to_string()));
thread::spawn(move || timed_stop(35, manager_clone));
@ -307,7 +319,6 @@ fn playlist_change_before_midnight() {
#[ignore]
fn playlist_change_at_six() {
let (mut config, manager) = get_config();
let manager_clone = manager.clone();
config.general.skip_validation = true;
config.mail.recipient = "".into();
@ -325,7 +336,10 @@ fn playlist_change_at_six() {
config.output.output_filter = None;
config.output.output_cmd = Some(vec_strings!["-f", "null", "-"]);
set_mock_time(&Some("2023-02-09T05:59:45".to_string()));
manager.update_config(config);
let manager_clone = manager.clone();
set_mock_time(&Some("2023-02-09T05:59:45+01:00".to_string()));
thread::spawn(move || timed_stop(28, manager_clone));

View File

@ -2,6 +2,7 @@ use sqlx::sqlite::SqlitePoolOptions;
use tokio::runtime::Runtime;
use chrono::prelude::*;
use serial_test::serial;
use ffplayout::db::handles;
use ffplayout::player::{controller::ChannelManager, utils::*};
@ -40,9 +41,10 @@ fn get_config() -> (PlayoutConfig, ChannelManager) {
}
#[test]
#[serial]
fn mock_date_time() {
let time_str = "2022-05-20T06:00:00";
let date_obj = NaiveDateTime::parse_from_str(time_str, "%Y-%m-%dT%H:%M:%S");
let time_str = "2022-05-20T06:00:00+02:00";
let date_obj = NaiveDateTime::parse_from_str(time_str, "%Y-%m-%dT%H:%M:%S%z");
let time = Local.from_local_datetime(&date_obj.unwrap()).unwrap();
set_mock_time(&Some(time_str.to_string()));
@ -54,8 +56,9 @@ fn mock_date_time() {
}
#[test]
#[serial]
fn get_date_yesterday() {
set_mock_time(&Some("2022-05-20T05:59:24".to_string()));
set_mock_time(&Some("2022-05-20T05:59:24+02:00".to_string()));
let date = get_date(true, 21600.0, false);
@ -63,8 +66,9 @@ fn get_date_yesterday() {
}
#[test]
#[serial]
fn get_date_tomorrow() {
set_mock_time(&Some("2022-05-20T23:59:58".to_string()));
set_mock_time(&Some("2022-05-20T23:59:58+02:00".to_string()));
let date = get_date(false, 0.0, true);
@ -72,6 +76,7 @@ fn get_date_tomorrow() {
}
#[test]
#[serial]
fn test_delta() {
let (mut config, _) = get_config();
@ -80,7 +85,7 @@ fn test_delta() {
config.playlist.day_start = "00:00:00".into();
config.playlist.length = "24:00:00".into();
set_mock_time(&Some("2022-05-09T23:59:59".to_string()));
set_mock_time(&Some("2022-05-09T23:59:59+02:00".to_string()));
let (delta, _) = get_delta(&config, &86401.0);
assert!(delta < 2.0);