about summary refs log tree commit diff stats
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/libmpv2/src/mpv.rs8
-rw-r--r--crates/libmpv2/src/tests.rs37
-rw-r--r--crates/yt_dlp/src/duration.rs4
-rw-r--r--crates/yt_dlp/src/tests.rs16
4 files changed, 45 insertions, 20 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]
diff --git a/crates/yt_dlp/src/duration.rs b/crates/yt_dlp/src/duration.rs
index f91892d..19181a5 100644
--- a/crates/yt_dlp/src/duration.rs
+++ b/crates/yt_dlp/src/duration.rs
@@ -68,11 +68,11 @@ mod test {
     #[test]
     fn test_display_duration_1h() {
         let dur = Duration { time: 60 * 60 };
-        assert_eq!("[1h 0m]".to_owned(), dur.to_string());
+        assert_eq!("1h 0m".to_owned(), dur.to_string());
     }
     #[test]
     fn test_display_duration_30min() {
         let dur = Duration { time: 60 * 30 };
-        assert_eq!("[30m 0s]".to_owned(), dur.to_string());
+        assert_eq!("30m 0s".to_owned(), dur.to_string());
     }
 }
diff --git a/crates/yt_dlp/src/tests.rs b/crates/yt_dlp/src/tests.rs
index 08e392f..b48deb4 100644
--- a/crates/yt_dlp/src/tests.rs
+++ b/crates/yt_dlp/src/tests.rs
@@ -34,10 +34,10 @@ async fn test_extract_info_video() {
         false,
     )
     .await
-    .map_err(|err| format!("Encountered error: '{}'", err))
+    .map_err(|err| format!("Encountered error: '{err}'"))
     .unwrap();
 
-    println!("{:#?}", info);
+    println!("{info:#?}");
 }
 
 #[tokio::test]
@@ -49,10 +49,10 @@ async fn test_extract_info_url() {
         false,
     )
     .await
-    .map_err(|err| format!("Encountered error: '{}'", err))
+    .map_err(|err| format!("Encountered error: '{err}'"))
     .unwrap();
 
-    println!("{:#?}", err);
+    println!("{err:#?}");
 }
 
 #[tokio::test]
@@ -64,10 +64,10 @@ async fn test_extract_info_playlist() {
         true,
     )
     .await
-    .map_err(|err| format!("Encountered error: '{}'", err))
+    .map_err(|err| format!("Encountered error: '{err}'"))
     .unwrap();
 
-    println!("{:#?}", err);
+    println!("{err:#?}");
 }
 #[tokio::test]
 async fn test_extract_info_playlist_full() {
@@ -78,8 +78,8 @@ async fn test_extract_info_playlist_full() {
         true,
     )
     .await
-    .map_err(|err| format!("Encountered error: '{}'", err))
+    .map_err(|err| format!("Encountered error: '{err}'"))
     .unwrap();
 
-    println!("{:#?}", err);
+    println!("{err:#?}");
 }