diff options
author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-08-23 18:26:25 +0200 |
---|---|---|
committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2024-08-24 11:45:13 +0200 |
commit | ee576400ce9c9e4f5d4ce420987ffd3ebe8ff5e0 (patch) | |
tree | 17c3e56fa20196a3ca8a04dadd2b81c96e843218 /src/storage | |
parent | feat(select/cmds): Add a `watched` command (diff) | |
download | yt-ee576400ce9c9e4f5d4ce420987ffd3ebe8ff5e0.tar.gz yt-ee576400ce9c9e4f5d4ce420987ffd3ebe8ff5e0.zip |
test(storage/setters): Assert the video status in `set_video_watched`
Diffstat (limited to '')
-rw-r--r-- | src/storage/video_database/setters.rs | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/storage/video_database/setters.rs b/src/storage/video_database/setters.rs index fcafcd4..c160138 100644 --- a/src/storage/video_database/setters.rs +++ b/src/storage/video_database/setters.rs @@ -12,7 +12,7 @@ use anyhow::Result; use chrono::Utc; -use log::debug; +use log::{debug, info}; use sqlx::query; use tokio::fs; @@ -116,6 +116,8 @@ pub async fn set_video_watched(app: &App, video: &Video) -> Result<()> { let video_hash = video.extractor_hash.hash().to_string(); let new_status = VideoStatus::Watched.as_db_integer(); + info!("Will set video watched: '{}'", video.title); + let old = query!( r#" SELECT status, priority @@ -127,9 +129,15 @@ pub async fn set_video_watched(app: &App, video: &Video) -> Result<()> { .fetch_one(&app.database) .await?; - if old.status == new_status { - unreachable!("The video should not be marked as watched already.") - } + assert_ne!( + old.status, new_status, + "The video should not be marked as watched already." + ); + assert_eq!( + old.status, + VideoStatus::Cached.as_db_integer(), + "The video should have been marked cached" + ); let now = Utc::now().timestamp(); @@ -180,7 +188,7 @@ pub async fn set_state_change( pub async fn set_video_options( app: &App, - hash: ExtractorHash, + hash: &ExtractorHash, video_options: &VideoOptions, ) -> Result<()> { let video_extractor_hash = hash.hash().to_string(); |