summaryrefslogtreecommitdiff
path: root/server/common/src/tests.rs
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2025-02-06 00:05:57 +0100
committerJoel Klinghed <the_jk@spawned.biz>2025-02-06 00:05:57 +0100
commitbd74717e10fb36e19893c15941876b2383b94714 (patch)
tree5fc26ace64c37fb439ba94cc5ea437a0e93913d2 /server/common/src/tests.rs
parent350fc534de745f4cc62000fa25d67afcddb7918a (diff)
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.
Diffstat (limited to 'server/common/src/tests.rs')
-rw-r--r--server/common/src/tests.rs19
1 files changed, 18 insertions, 1 deletions
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("<invalid>").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());
+}