Fix failing tests

This commit is contained in:
Joel Wachsler 2022-07-10 16:04:51 +00:00
parent 6c230e6407
commit 3d0b01eba0
2 changed files with 30 additions and 9 deletions

View File

@ -1,5 +1,6 @@
use anyhow::Result;
use api_gen::QBittorrentApiGen;
use tokio::time::{sleep, Duration};
const USERNAME: &str = "admin";
const PASSWORD: &str = "adminadmin";
@ -16,9 +17,19 @@ async fn main() -> Result<()> {
const TORRENT_URL: &str = "http://www.legittorrents.info/download.php?id=5cc013e801095be61d768e609e3039da58616fd0&f=Oddepoxy%20-%20Oddepoxy%20(2013)%20[OGG%20320%20CBR].torrent";
let _ = api.torrent_management().add(TORRENT_URL).send().await?;
let mut tries = 5;
while tries > 0 {
let info = api.torrent_management().info().send().await?;
let first = &info[0];
assert_ne!(first.state, api_impl::TorrentManagementInfoState::Unknown);
if let Some(first) = &info.get(0) {
// just check that something is there
assert_ne!(first.added_on, 0);
return Ok(());
} else {
tries -= 1;
println!("torrent not found, sleeping for 1 second");
sleep(Duration::from_secs(1)).await;
}
}
Ok(())
panic!("Failed to find torrent!");
}

View File

@ -1,5 +1,6 @@
use anyhow::Result;
use api_gen::QBittorrentApiGen;
use tokio::time::{sleep, Duration};
const USERNAME: &str = "admin";
const PASSWORD: &str = "adminadmin";
@ -16,10 +17,19 @@ async fn main() -> Result<()> {
const TORRENT_URL: &str = "http://www.legittorrents.info/download.php?id=5cc013e801095be61d768e609e3039da58616fd0&f=Oddepoxy%20-%20Oddepoxy%20(2013)%20[OGG%20320%20CBR].torrent";
let _ = api.torrent_management().add(TORRENT_URL).send().await?;
let mut tries = 5;
while tries > 0 {
let info = api.torrent_management().info().send().await?;
let first = &info[0];
if let Some(first) = &info.get(0) {
// just check that something is there
assert_ne!(first.added_on, 0);
return Ok(());
} else {
tries -= 1;
println!("torrent not found, sleeping for 1 second");
sleep(Duration::from_secs(1)).await;
}
}
Ok(())
panic!("Failed to find torrent!");
}