Fix failing tests
This commit is contained in:
parent
6c230e6407
commit
3d0b01eba0
|
@ -1,5 +1,6 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use api_gen::QBittorrentApiGen;
|
use api_gen::QBittorrentApiGen;
|
||||||
|
use tokio::time::{sleep, Duration};
|
||||||
|
|
||||||
const USERNAME: &str = "admin";
|
const USERNAME: &str = "admin";
|
||||||
const PASSWORD: &str = "adminadmin";
|
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";
|
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 _ = api.torrent_management().add(TORRENT_URL).send().await?;
|
||||||
|
|
||||||
let info = api.torrent_management().info().send().await?;
|
let mut tries = 5;
|
||||||
let first = &info[0];
|
while tries > 0 {
|
||||||
assert_ne!(first.state, api_impl::TorrentManagementInfoState::Unknown);
|
let info = api.torrent_management().info().send().await?;
|
||||||
|
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!");
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use api_gen::QBittorrentApiGen;
|
use api_gen::QBittorrentApiGen;
|
||||||
|
use tokio::time::{sleep, Duration};
|
||||||
|
|
||||||
const USERNAME: &str = "admin";
|
const USERNAME: &str = "admin";
|
||||||
const PASSWORD: &str = "adminadmin";
|
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";
|
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 _ = api.torrent_management().add(TORRENT_URL).send().await?;
|
||||||
|
|
||||||
let info = api.torrent_management().info().send().await?;
|
let mut tries = 5;
|
||||||
let first = &info[0];
|
while tries > 0 {
|
||||||
// just check that something is there
|
let info = api.torrent_management().info().send().await?;
|
||||||
assert_ne!(first.added_on, 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!");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user