From bd74717e10fb36e19893c15941876b2383b94714 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Thu, 6 Feb 2025 00:05:57 +0100 Subject: Add DELETE command for review Only the owner or a maintainer of the project can remove a review. Removing a review also removes the git branch. Only reviews that are either draft or dropped can be removed. --- server/common/src/tests.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'server/common/src/tests.rs') diff --git a/server/common/src/tests.rs b/server/common/src/tests.rs index f08ca44..41f44fe 100644 --- a/server/common/src/tests.rs +++ b/server/common/src/tests.rs @@ -202,7 +202,7 @@ async fn git_get_author_commiter(repo: &git::Repository) { assert!(repo.get_author("").await.is_err()); } -async fn git_fetch(bare: bool) { +async fn git_fetch(bare: bool) -> git::Repository { let path = testdir!().join("repo"); let remote_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("src/testdata/bare"); let remote = remote_path.to_string_lossy().into_owned(); @@ -231,6 +231,7 @@ async fn git_fetch(bare: bool) { branch.unwrap(); other.unwrap(); } + repo } #[tokio::test] @@ -266,3 +267,19 @@ async fn test_git_fetch() { async fn test_git_bare_fetch() { git_fetch(true).await; } + +#[tokio::test] +async fn test_git_delete_branch() { + // Using git_fetch as we need a writeable git repo + let repo = git_fetch(false).await; + assert!(repo.delete_branch("other").await.is_ok()); + assert!(repo.delete_branch("does-not-exist").await.is_err()); +} + +#[tokio::test] +async fn test_git_bare_delete_branch() { + // Using git_fetch as we need a writeable git repo + let repo = git_fetch(true).await; + assert!(repo.delete_branch("other").await.is_ok()); + assert!(repo.delete_branch("does-not-exist").await.is_err()); +} -- cgit v1.2.3-70-g09d2