aboutsummaryrefslogtreecommitdiffstats
path: root/models/issues/dependency_test.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2024-12-24 23:38:30 -0800
committerGitHub <noreply@github.com>2024-12-25 07:38:30 +0000
commit5feb1a6bff6b6931ebe197258032557f55e32c6c (patch)
tree48e3aeb50c12c6bbffa86b0bea7cc9b22c1baf51 /models/issues/dependency_test.go
parentf44712f22bc7bfce049c64c27f60453ff1e41a5c (diff)
downloadgitea-5feb1a6bff6b6931ebe197258032557f55e32c6c.tar.gz
gitea-5feb1a6bff6b6931ebe197258032557f55e32c6c.zip
Use `CloseIssue` and `ReopenIssue` instead of `ChangeStatus` (#32467)
The behaviors of closing issues and reopening issues are very different. So splitting it into two different functions makes it easier to maintain. - [x] Split ChangeIssueStatus into CloseIssue and ReopenIssue both at the service layer and model layer - [x] Rename `isClosed` to `CloseOrReopen` to make it more readable. - [x] Add transactions for ReopenIssue and CloseIssue --------- Co-authored-by: Zettat123 <zettat123@gmail.com>
Diffstat (limited to 'models/issues/dependency_test.go')
-rw-r--r--models/issues/dependency_test.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/models/issues/dependency_test.go b/models/issues/dependency_test.go
index 6eed483cc9..67418039de 100644
--- a/models/issues/dependency_test.go
+++ b/models/issues/dependency_test.go
@@ -49,9 +49,13 @@ func TestCreateIssueDependency(t *testing.T) {
assert.False(t, left)
// Close #2 and check again
- _, err = issues_model.ChangeIssueStatus(db.DefaultContext, issue2, user1, true)
+ _, err = issues_model.CloseIssue(db.DefaultContext, issue2, user1)
assert.NoError(t, err)
+ issue2Closed, err := issues_model.GetIssueByID(db.DefaultContext, 2)
+ assert.NoError(t, err)
+ assert.True(t, issue2Closed.IsClosed)
+
left, err = issues_model.IssueNoDependenciesLeft(db.DefaultContext, issue1)
assert.NoError(t, err)
assert.True(t, left)
@@ -59,4 +63,11 @@ func TestCreateIssueDependency(t *testing.T) {
// Test removing the dependency
err = issues_model.RemoveIssueDependency(db.DefaultContext, user1, issue1, issue2, issues_model.DependencyTypeBlockedBy)
assert.NoError(t, err)
+
+ _, err = issues_model.ReopenIssue(db.DefaultContext, issue2, user1)
+ assert.NoError(t, err)
+
+ issue2Reopened, err := issues_model.GetIssueByID(db.DefaultContext, 2)
+ assert.NoError(t, err)
+ assert.False(t, issue2Reopened.IsClosed)
}