Skip to content

Commit

Permalink
test: new test for admin users to delete torrents
Browse files Browse the repository at this point in the history
  • Loading branch information
mario-nt committed Oct 10, 2024
1 parent 3e14319 commit 4c094db
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion tests/e2e/web/api/v1/contexts/torrent/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,13 @@ mod and_admins {
client::Client,
contexts::torrent::{fixtures::random_torrent, forms::UploadTorrentMultipartForm},
},
e2e::{environment::TestEnv, web::api::v1::contexts::user::steps::new_logged_in_admin},
e2e::{
environment::TestEnv,
web::api::v1::contexts::{
torrent::steps::upload_random_torrent_to_index,
user::steps::{new_logged_in_admin, new_logged_in_user},
},
},
};

#[tokio::test]
Expand All @@ -1392,5 +1398,26 @@ mod and_admins {

assert_eq!(response.status, 200);
}

#[tokio::test]
async fn it_should_allow_admin_users_to_delete_torrents() {
let mut env = TestEnv::new();
env.start(api::Version::V1).await;

if !env.provides_a_tracker() {
println!("test skipped. It requires a tracker to be running.");
return;
}

let uploader = new_logged_in_user(&env).await;
let (test_torrent, _uploaded_torrent) = upload_random_torrent_to_index(&uploader, &env).await;

let admin = new_logged_in_admin(&env).await;
let client = Client::authenticated(&env.server_socket_addr().unwrap(), &admin.token);

let response = client.delete_torrent(&test_torrent.file_info_hash()).await;

assert_eq!(response.status, 200);
}
}
}

0 comments on commit 4c094db

Please sign in to comment.