diff --git a/Cargo.lock b/Cargo.lock index a7705ec..2b12956 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1192,7 +1192,7 @@ dependencies = [ [[package]] name = "tootube" -version = "0.7.0" +version = "0.7.1" dependencies = [ "async-stream", "clap", diff --git a/Cargo.toml b/Cargo.toml index 8156dfe..60b4a3a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "tootube" authors = ["VC "] -version = "0.7.0" +version = "0.7.1" edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/src/peertube.rs b/src/peertube.rs index da86a49..a30eb14 100644 --- a/src/peertube.rs +++ b/src/peertube.rs @@ -503,3 +503,49 @@ pub async fn get_playlists_to_be_added_to( Ok(playlist_to_be_added_to) } + +#[cfg(test)] +mod tests { + use super::*; + + #[tokio::test] + async fn test_get_latest_video() { + let peertube = PeerTube::new("https://peertube.cpy.re"); + + let vid = peertube.get_latest_video().await.unwrap(); + + assert_eq!(vid.uuid.len(), 36); + } + + #[tokio::test] + #[should_panic] + async fn test_get_original_video_source() { + let peertube = PeerTube::new("https://peertube.cpy.re"); + + let _vid = peertube + .get_original_video_source("t") + .await + .expect("Should panic!"); + } + + #[tokio::test] + async fn test_list_video_playlists() { + let peertube = PeerTube::new("https://peertube.cpy.re"); + + let pl = peertube.list_video_playlists().await.unwrap(); + + assert!(!pl.is_empty()); + } + + #[tokio::test] + async fn test_list_videos_playlist() { + let peertube = PeerTube::new("https://peertube.cpy.re"); + + let pl_videos = peertube + .list_videos_playlist("73a5c1fa-64c5-462d-81e5-b120781c2d72") + .await + .unwrap(); + + assert!(!pl_videos.is_empty()); + } +}