You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hydrus-api-rs/tests/client/test_adding_files.rs

54 lines
1.6 KiB
Rust

use crate::common;
use crate::common::create_testdata;
use crate::common::test_data::get_test_hashes;
use hydrus_api::api_core::endpoints::adding_files::DeleteFilesRequest;
use hydrus_api::wrapper::service::ServiceName;
#[tokio::test]
async fn it_adds_files() {
let client = common::get_client();
let result = client.add_file("/does/not/exist").await;
assert!(result.is_err()); // because the path does not exist
}
#[tokio::test]
async fn it_adds_binary_files() {
let client = common::get_client();
let result = client
.add_binary_file(vec![0u8, 0u8, 0u8, 0u8])
.await
.unwrap();
assert_eq!(result.status, 4); // should fail because the filetype is unknown
}
#[tokio::test]
async fn it_deletes_files() {
let client = common::get_client();
create_testdata(&client).await;
let mut delete_request = DeleteFilesRequest::new(get_test_hashes(), vec![]);
delete_request.set_reason("Testing");
delete_request.set_service(ServiceName::my_files().into());
client.delete_files(delete_request).await.unwrap();
}
#[tokio::test]
async fn it_undeletes_files() {
let client = common::get_client();
create_testdata(&client).await;
client.undelete_files(get_test_hashes()).await.unwrap();
}
#[tokio::test]
async fn it_archives_files() {
let client = common::get_client();
create_testdata(&client).await;
client.archive_files(get_test_hashes()).await.unwrap();
}
#[tokio::test]
async fn it_unarchives_files() {
let client = common::get_client();
create_testdata(&client).await;
client.unarchive_files(get_test_hashes()).await.unwrap();
}