Merge branch '8-this-lacks-tests' into 'master'

Resolve "This lacks tests"

Closes #8

See merge request veretcle/tootube!22
This commit is contained in:
VC
2024-05-17 10:02:57 +00:00
3 changed files with 48 additions and 2 deletions

2
Cargo.lock generated
View File

@@ -1192,7 +1192,7 @@ dependencies = [
[[package]]
name = "tootube"
version = "0.7.0"
version = "0.7.1"
dependencies = [
"async-stream",
"clap",

View File

@@ -1,7 +1,7 @@
[package]
name = "tootube"
authors = ["VC <veretcle+framagit@mateu.be>"]
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

View File

@@ -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());
}
}