feat(readarr): fetch Readarr root folders and expose them on the CLI
Adds the GetRootFolders event backed by GET /rootfolder, storing the result on the Readarr root folders table, and surfaces it as "managarr readarr list root-folders". Root folders reuse the shared RootFolder model. Readarr omits the unmappedFolders key that the other servarrs return, and the field is optional, so it deserializes to None without changing the shared type. Only the read path is included here. Adding and deleting root folders mutate the library layout, so they are left for separate work.
This commit is contained in:
6 files changed
+236
No files matched your search
@@ -35,6 +35,8 @@ pub enum ReadarrListCommand {
|
||||
QualityProfiles,
|
||||
#[command(about = "List all queued events")]
|
||||
QueuedEvents,
|
||||
#[command(about = "List all root folders in Readarr")]
|
||||
RootFolders,
|
||||
#[command(about = "List all Readarr tags")]
|
||||
Tags,
|
||||
#[command(about = "List all Readarr tasks")]
|
||||
@@ -115,6 +117,13 @@ impl<'a, 'b> CliCommandHandler<'a, 'b, ReadarrListCommand> for ReadarrListComman
|
||||
.await?;
|
||||
serde_json::to_string_pretty(&resp)?
|
||||
}
|
||||
ReadarrListCommand::RootFolders => {
|
||||
let resp = self
|
||||
.network
|
||||
.handle_network_event(ReadarrEvent::GetRootFolders.into())
|
||||
.await?;
|
||||
serde_json::to_string_pretty(&resp)?
|
||||
}
|
||||
ReadarrListCommand::Tags => {
|
||||
let resp = self
|
||||
.network
|
||||
|
||||
@@ -30,6 +30,7 @@ mod tests {
|
||||
"metadata-profiles",
|
||||
"quality-profiles",
|
||||
"queued-events",
|
||||
"root-folders",
|
||||
"tags",
|
||||
"tasks",
|
||||
"updates"
|
||||
@@ -242,6 +243,29 @@ mod tests {
|
||||
assert_ok!(&result);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_handle_list_root_folders_command() {
|
||||
let mut mock_network = MockNetworkTrait::new();
|
||||
mock_network
|
||||
.expect_handle_network_event()
|
||||
.with(eq::<NetworkEvent>(ReadarrEvent::GetRootFolders.into()))
|
||||
.times(1)
|
||||
.returning(|_| {
|
||||
Ok(Serdeable::Readarr(ReadarrSerdeable::Value(
|
||||
json!({"testResponse": "response"}),
|
||||
)))
|
||||
});
|
||||
let app_arc = Arc::new(Mutex::new(App::test_default()));
|
||||
let list_root_folders_command = ReadarrListCommand::RootFolders;
|
||||
|
||||
let result =
|
||||
ReadarrListCommandHandler::with(&app_arc, list_root_folders_command, &mut mock_network)
|
||||
.handle()
|
||||
.await;
|
||||
|
||||
assert_ok!(&result);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_handle_list_tags_command() {
|
||||
let mut mock_network = MockNetworkTrait::new();
|
||||
|
||||
Reference in new issue
Block a user