feat: CLI and TUI support for track history and track details in Lidarr
This commit is contained in:
@@ -7,7 +7,9 @@ mod tests {
|
||||
use crate::models::servarr_models::Indexer;
|
||||
use crate::network::NetworkEvent;
|
||||
use crate::network::lidarr_network::LidarrEvent;
|
||||
use crate::network::lidarr_network::lidarr_network_test_utils::test_utils::artist;
|
||||
use crate::network::lidarr_network::lidarr_network_test_utils::test_utils::{
|
||||
album, artist, track,
|
||||
};
|
||||
use pretty_assertions::{assert_eq, assert_str_eq};
|
||||
use tokio::sync::mpsc;
|
||||
|
||||
@@ -464,6 +466,46 @@ mod tests {
|
||||
assert_eq!(app.tick_count, 0);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_dispatch_by_track_details_block() {
|
||||
let (tx, mut rx) = mpsc::channel::<NetworkEvent>(500);
|
||||
let mut app = App::test_default_fully_populated();
|
||||
app.data.lidarr_data.prompt_confirm = true;
|
||||
app.network_tx = Some(tx);
|
||||
|
||||
app
|
||||
.dispatch_by_lidarr_block(&ActiveLidarrBlock::TrackDetails)
|
||||
.await;
|
||||
|
||||
assert!(app.is_loading);
|
||||
assert_eq!(
|
||||
rx.recv().await.unwrap(),
|
||||
LidarrEvent::GetTrackDetails(1).into()
|
||||
);
|
||||
assert!(!app.data.lidarr_data.prompt_confirm);
|
||||
assert_eq!(app.tick_count, 0);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_dispatch_by_track_history_block() {
|
||||
let (tx, mut rx) = mpsc::channel::<NetworkEvent>(500);
|
||||
let mut app = App::test_default_fully_populated();
|
||||
app.data.lidarr_data.prompt_confirm = true;
|
||||
app.network_tx = Some(tx);
|
||||
|
||||
app
|
||||
.dispatch_by_lidarr_block(&ActiveLidarrBlock::TrackHistory)
|
||||
.await;
|
||||
|
||||
assert!(app.is_loading);
|
||||
assert_eq!(
|
||||
rx.recv().await.unwrap(),
|
||||
LidarrEvent::GetTrackHistory(1, 1, 1).into()
|
||||
);
|
||||
assert!(!app.data.lidarr_data.prompt_confirm);
|
||||
assert_eq!(app.tick_count, 0);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_check_for_lidarr_prompt_action_no_prompt_confirm() {
|
||||
let mut app = App::test_default();
|
||||
@@ -684,6 +726,32 @@ mod tests {
|
||||
assert_eq!(app.extract_artist_id().await, 1);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_extract_album_id() {
|
||||
let mut app = App::test_default();
|
||||
app.data.lidarr_data.albums.set_items(vec![album()]);
|
||||
|
||||
assert_eq!(app.extract_album_id().await, 1);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_extract_track_id() {
|
||||
let mut app = App::test_default();
|
||||
let mut album_details_modal = AlbumDetailsModal::default();
|
||||
album_details_modal.tracks.set_items(vec![track()]);
|
||||
app.data.lidarr_data.album_details_modal = Some(album_details_modal);
|
||||
|
||||
assert_eq!(app.extract_track_id().await, 1);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[should_panic(expected = "album_details_modal is empty")]
|
||||
async fn test_extract_track_id_panics_when_album_details_modal_is_not_set() {
|
||||
let app = App::test_default();
|
||||
|
||||
app.extract_track_id().await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_extract_lidarr_indexer_id() {
|
||||
let mut app = App::test_default();
|
||||
|
||||
Reference in New Issue
Block a user