mirror of
https://github.com/euzu/tuliprox.git
synced 2026-10-14 20:02:18 +02:00
Handling edge cases for series info parsing
This commit is contained in:
@@ -554,26 +554,31 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn parse_test() -> io::Result<()> {
|
||||
//let file_path = PathBuf::from("/tmp/epg.xml.gz");
|
||||
let file_path = PathBuf::from("/tmp/invalid_epg.xml");
|
||||
let run_test = async move || {
|
||||
//let file_path = PathBuf::from("/tmp/epg.xml.gz");
|
||||
let file_path = PathBuf::from("/tmp/invalid_epg.xml");
|
||||
|
||||
if file_path.exists() {
|
||||
let tv_guide = TVGuide::new(vec![PersistedEpgSource { file_path, priority: 0, logo_override: false }]);
|
||||
if file_path.exists() {
|
||||
let tv_guide = TVGuide::new(vec![PersistedEpgSource { file_path, priority: 0, logo_override: false }]);
|
||||
|
||||
let mut id_cache = EpgIdCache::new(None);
|
||||
id_cache.channel_epg_id.insert(Cow::Owned("342".to_string()));
|
||||
//id_cache.collect_epg_id(fp);
|
||||
let mut id_cache = EpgIdCache::new(None);
|
||||
id_cache.channel_epg_id.insert(Cow::Owned("342".to_string()));
|
||||
//id_cache.collect_epg_id(fp);
|
||||
|
||||
let channel_ids = HashSet::from(["342".to_string()]);
|
||||
match tv_guide.filter(&mut id_cache) {
|
||||
None => assert!(false, "No epg filtered"),
|
||||
Some(epgs) => {
|
||||
for epg in epgs {
|
||||
assert_eq!(epg.children.len(), channel_ids.len() * 2, "Epg size does not match")
|
||||
let channel_ids = HashSet::from(["342".to_string()]);
|
||||
match tv_guide.filter(&mut id_cache).await {
|
||||
None => assert!(false, "No epg filtered"),
|
||||
Some(epgs) => {
|
||||
for epg in epgs {
|
||||
assert_eq!(epg.children.len(), channel_ids.len() * 2, "Epg size does not match")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
let _result = tokio::runtime::Runtime::new()
|
||||
.unwrap()
|
||||
.block_on(run_test());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -208,8 +208,13 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn test_read_json_file_into_struct() {
|
||||
let file_content = fs::read_to_string("series-info.json").expect("Unable to read file");
|
||||
let _info: XtreamSeriesInfo = serde_json::from_str(&file_content).expect("JSON was not well-formatted");
|
||||
let file_content = fs::read_to_string("/tmp/series-info.json").expect("Unable to read file");
|
||||
match serde_json::from_str::<XtreamSeriesInfo>(&file_content) {
|
||||
Ok(series_info) => {},
|
||||
Err(err) => {
|
||||
assert!(false, "Failed to parse json file: {err}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user