use crate::prelude::*;
impl GazelleClient {
pub async fn get_torrent(&self, id: u32) -> Result<TorrentResponse, GazelleError> {
self.get(format!("action=torrent&id={id}")).await
}
}
#[cfg(test)]
mod tests {
use crate::prelude::*;
use serial_test::serial;
#[tokio::test]
#[serial]
#[ignore = "integration test requiring API credentials"]
async fn get_torrent() -> Result<(), GazelleError> {
for_each_indexer(|name, client, examples| async move {
let response = client.lock().await.get_torrent(examples.torrent).await?;
assert_eq!(
response.torrent.id, examples.torrent,
"[{name}] torrent id mismatch"
);
Ok(())
})
.await
}
#[tokio::test]
#[serial]
#[ignore = "integration test requiring API credentials"]
async fn get_torrent_invalid() -> Result<(), GazelleError> {
for_each_indexer(|name, client, _examples| async move {
let error = client
.lock()
.await
.get_torrent(u32::MAX)
.await
.expect_err("should be an error");
assert_eq!(
error.operation,
GazelleOperation::ApiResponse(ApiResponseKind::BadRequest),
"[{name}] expected BadRequest, got {error:?}"
);
Ok(())
})
.await
}
}