diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-10-14 20:59:32 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-10-14 21:02:12 +0200 |
commit | baffdf885aab7490e1024a73f8ee3ce35817c586 (patch) | |
tree | c2775b605b27cf9293dfdd2e2b933f5c3def26d8 /crates/libmpv2 | |
parent | build(scripts/mkdb.sh): Update to use new sql schema path (diff) | |
download | yt-baffdf885aab7490e1024a73f8ee3ce35817c586.tar.gz yt-baffdf885aab7490e1024a73f8ee3ce35817c586.zip |
test(treewide): Fix, so they compile and ignore
The tests are just not in an ideal state right now. Running them via `cargo test` still works, but the `yt_dlp` test simply seem to deadlock?
Diffstat (limited to '')
-rw-r--r-- | crates/libmpv2/src/mpv.rs | 8 | ||||
-rw-r--r-- | crates/libmpv2/src/tests.rs | 37 |
2 files changed, 35 insertions, 10 deletions
diff --git a/crates/libmpv2/src/mpv.rs b/crates/libmpv2/src/mpv.rs index bf4581e..07d0976 100644 --- a/crates/libmpv2/src/mpv.rs +++ b/crates/libmpv2/src/mpv.rs @@ -566,15 +566,21 @@ impl Mpv { /// /// # Examples /// - /// ``` + /// ```dont_run /// # use libmpv2::{Mpv}; /// # use libmpv2::mpv_node::MpvNode; + /// # use libmpv2::mpv::errors::Result; /// # use std::collections::HashMap; + /// # + /// # fn main() -> Result<()> { + /// # let mpv = Mpv::new()?; /// mpv.command("loadfile", &["test-data/jellyfish.mp4", "append-play"]).unwrap(); /// # let node = mpv.get_property::<MpvNode>("playlist").unwrap(); /// # let mut list = node.array().unwrap().collect::<Vec<_>>(); /// # let map = list.pop().unwrap().map().unwrap().collect::<HashMap<_, _>>(); /// # assert_eq!(map, HashMap::from([(String::from("id"), MpvNode::Int64(1)), (String::from("current"), MpvNode::Flag(true)), (String::from("filename"), MpvNode::String(String::from("test-data/jellyfish.mp4")))])); + /// # Ok(()) + /// # } /// ``` pub fn command(&self, name: &str, args: &[&str]) -> Result<()> { let mut cmd = name.to_owned(); diff --git a/crates/libmpv2/src/tests.rs b/crates/libmpv2/src/tests.rs index 1e7635d..68753fc 100644 --- a/crates/libmpv2/src/tests.rs +++ b/crates/libmpv2/src/tests.rs @@ -8,6 +8,10 @@ // You should have received a copy of the License along with this program. // If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>. +#![allow(clippy::bool_assert_comparison)] + +use events::EndFileEvent; + use crate::events::{Event, EventContext, PropertyData}; use crate::mpv_node::MpvNode; use crate::*; @@ -33,6 +37,7 @@ fn initializer() { } #[test] +#[ignore = "The required test-data is missing"] fn properties() { let mpv = Mpv::new().unwrap(); mpv.set_property("volume", 0).unwrap(); @@ -77,6 +82,7 @@ macro_rules! assert_event_occurs { } #[test] +#[ignore = "The required test-data is missing"] fn events() { let mpv = Mpv::new().unwrap(); let mut ev_ctx = EventContext::new(mpv.ctx); @@ -115,7 +121,7 @@ fn events() { assert!(ev_ctx.wait_event(3.).is_none()); mpv.command("loadfile", &["test-data/jellyfish.mp4", "append-play"]) .unwrap(); - assert_event_occurs!(ev_ctx, 10., Ok(Event::StartFile)); + assert_event_occurs!(ev_ctx, 10., Ok(Event::StartFile(_))); assert_event_occurs!( ev_ctx, 10., @@ -136,8 +142,15 @@ fn events() { assert_event_occurs!(ev_ctx, 3., Ok(Event::VideoReconfig)); assert_event_occurs!(ev_ctx, 3., Ok(Event::AudioReconfig)); assert_event_occurs!(ev_ctx, 3., Ok(Event::VideoReconfig)); - assert_event_occurs!(ev_ctx, 3., Ok(Event::EndFile(mpv_end_file_reason::Stop))); - assert_event_occurs!(ev_ctx, 3., Ok(Event::StartFile)); + assert_event_occurs!( + ev_ctx, + 3., + Ok(Event::EndFile(EndFileEvent { + reason: EndFileReason::Stop, + .. + })) + ); + assert_event_occurs!(ev_ctx, 3., Ok(Event::StartFile(_))); assert_event_occurs!( ev_ctx, 3., @@ -155,14 +168,22 @@ fn events() { assert_event_occurs!(ev_ctx, 3., Ok(Event::AudioReconfig)); assert_event_occurs!(ev_ctx, 3., Ok(Event::PlaybackRestart)); assert_event_occurs!(ev_ctx, 3., Ok(Event::AudioReconfig)); - assert_event_occurs!(ev_ctx, 10., Ok(Event::EndFile(mpv_end_file_reason::Eof))); + assert_event_occurs!( + ev_ctx, + 10., + Ok(Event::EndFile(EndFileEvent { + reason: EndFileReason::Eof, + .. + })) + ); assert_event_occurs!(ev_ctx, 3., Ok(Event::AudioReconfig)); assert!(ev_ctx.wait_event(3.).is_none()); } #[test] -fn node_map() -> Result<()> { - let mpv = Mpv::new()?; +#[ignore = "This test is missing the `test-data`"] +fn node_map() { + let mpv = Mpv::new().unwrap(); mpv.command( "loadfile", @@ -171,7 +192,7 @@ fn node_map() -> Result<()> { .unwrap(); thread::sleep(Duration::from_millis(250)); - let audio_params = mpv.get_property::<MpvNode>("audio-params")?; + let audio_params = mpv.get_property::<MpvNode>("audio-params").unwrap(); let params = audio_params.map().unwrap().collect::<HashMap<_, _>>(); assert_eq!(params.len(), 5); @@ -190,8 +211,6 @@ fn node_map() -> Result<()> { let channel_count = params.get("channel-count").unwrap(); assert_eq!(channel_count, &MpvNode::Int64(1)); - - Ok(()) } #[test] |