diff options
-rw-r--r-- | src/lib.rs | 7 | ||||
-rw-r--r-- | src/repository.rs | 26 | ||||
-rw-r--r-- | tests/ci_test.rs | 4 |
3 files changed, 29 insertions, 8 deletions
@@ -180,9 +180,12 @@ impl Forgejo { status => Err(ForgejoError::UnexpectedStatusCode(status)), } } - + /// Like `execute`, but returns a `String`. - async fn execute_opt_raw(&self, request: Request) -> Result<Option<bytes::Bytes>, ForgejoError> { + async fn execute_opt_raw( + &self, + request: Request, + ) -> Result<Option<bytes::Bytes>, ForgejoError> { let response = self.client.execute(request).await?; match response.status() { status if status.is_success() => Ok(Some(response.bytes().await?)), diff --git a/src/repository.rs b/src/repository.rs index 992f78a..d9a92b1 100644 --- a/src/repository.rs +++ b/src/repository.rs @@ -207,7 +207,12 @@ impl Forgejo { .await } - pub async fn download_release_zip(&self, owner: &str, repo: &str, release: u64) -> Result<Option<bytes::Bytes>, ForgejoError> { + pub async fn download_release_zip( + &self, + owner: &str, + repo: &str, + release: u64, + ) -> Result<Option<bytes::Bytes>, ForgejoError> { let release = self.get_release(owner, repo, release).await; let release = match release { Ok(Some(release)) => release, @@ -218,7 +223,12 @@ impl Forgejo { self.execute_opt_raw(request).await } - pub async fn download_release_tarball(&self, owner: &str, repo: &str, release: u64) -> Result<Option<bytes::Bytes>, ForgejoError> { + pub async fn download_release_tarball( + &self, + owner: &str, + repo: &str, + release: u64, + ) -> Result<Option<bytes::Bytes>, ForgejoError> { let release = self.get_release(owner, repo, release).await; let release = match release { Ok(Some(release)) => release, @@ -229,8 +239,16 @@ impl Forgejo { self.execute_opt_raw(request).await } - pub async fn download_release_attachment(&self, owner: &str, repo: &str, release: u64, attach: u64) -> Result<Option<bytes::Bytes>, ForgejoError> { - let release = self.get_release_attachment(owner, repo, release, attach).await?; + pub async fn download_release_attachment( + &self, + owner: &str, + repo: &str, + release: u64, + attach: u64, + ) -> Result<Option<bytes::Bytes>, ForgejoError> { + let release = self + .get_release_attachment(owner, repo, release, attach) + .await?; let request = self.client.get(release.browser_download_url).build()?; self.execute_opt_raw(request).await } diff --git a/tests/ci_test.rs b/tests/ci_test.rs index 5812074..e5cb1c2 100644 --- a/tests/ci_test.rs +++ b/tests/ci_test.rs @@ -224,10 +224,10 @@ async fn repo(api: &forgejo_api::Forgejo) -> eyre::Result<()> { api.download_release_attachment("TestingAdmin", "test", release.id, attachment.id) .await? .as_deref() - == Some(b"This is a file!"), + == Some(b"This is a file!"), "couldn't download attachment" ); - + api.delete_release_attachment("TestingAdmin", "test", release.id, attachment.id) .await .wrap_err("failed to deleted attachment")?; |