@@ -39,12 +39,12 @@ func TestAPICreateIssue(t *testing.T) {
39
39
defer prepareTestEnv (t )()
40
40
const body , title = "apiTestBody" , "apiTestTitle"
41
41
42
- repo := models .AssertExistsAndLoadBean (t , & models.Repository {ID : 1 }).(* models.Repository )
43
- owner := models .AssertExistsAndLoadBean (t , & models.User {ID : repo .OwnerID }).(* models.User )
42
+ repoBefore := models .AssertExistsAndLoadBean (t , & models.Repository {ID : 1 }).(* models.Repository )
43
+ owner := models .AssertExistsAndLoadBean (t , & models.User {ID : repoBefore .OwnerID }).(* models.User )
44
44
45
45
session := loginUser (t , owner .Name )
46
46
token := getTokenForLoggedInUser (t , session )
47
- urlStr := fmt .Sprintf ("/api/v1/repos/%s/%s/issues?state=all&token=%s" , owner .Name , repo .Name , token )
47
+ urlStr := fmt .Sprintf ("/api/v1/repos/%s/%s/issues?state=all&token=%s" , owner .Name , repoBefore .Name , token )
48
48
req := NewRequestWithJSON (t , "POST" , urlStr , & api.CreateIssueOption {
49
49
Body : body ,
50
50
Title : title ,
@@ -57,19 +57,23 @@ func TestAPICreateIssue(t *testing.T) {
57
57
assert .Equal (t , apiIssue .Title , title )
58
58
59
59
models .AssertExistsAndLoadBean (t , & models.Issue {
60
- RepoID : repo .ID ,
60
+ RepoID : repoBefore .ID ,
61
61
AssigneeID : owner .ID ,
62
62
Content : body ,
63
63
Title : title ,
64
64
})
65
+
66
+ repoAfter := models .AssertExistsAndLoadBean (t , & models.Repository {ID : 1 }).(* models.Repository )
67
+ assert .Equal (t , repoBefore .NumIssues + 1 , repoAfter .NumIssues )
68
+ assert .Equal (t , repoBefore .NumClosedIssues , repoAfter .NumClosedIssues )
65
69
}
66
70
67
71
func TestAPIEditIssue (t * testing.T ) {
68
72
defer prepareTestEnv (t )()
69
73
70
74
issueBefore := models .AssertExistsAndLoadBean (t , & models.Issue {ID : 10 }).(* models.Issue )
71
- repo := models .AssertExistsAndLoadBean (t , & models.Repository {ID : issueBefore .RepoID }).(* models.Repository )
72
- owner := models .AssertExistsAndLoadBean (t , & models.User {ID : repo .OwnerID }).(* models.User )
75
+ repoBefore := models .AssertExistsAndLoadBean (t , & models.Repository {ID : issueBefore .RepoID }).(* models.Repository )
76
+ owner := models .AssertExistsAndLoadBean (t , & models.User {ID : repoBefore .OwnerID }).(* models.User )
73
77
assert .NoError (t , issueBefore .LoadAttributes ())
74
78
assert .Equal (t , int64 (1019307200 ), int64 (issueBefore .DeadlineUnix ))
75
79
assert .Equal (t , api .StateOpen , issueBefore .State ())
@@ -84,7 +88,7 @@ func TestAPIEditIssue(t *testing.T) {
84
88
body := "new content!"
85
89
title := "new title from api set"
86
90
87
- urlStr := fmt .Sprintf ("/api/v1/repos/%s/%s/issues/%d?token=%s" , owner .Name , repo .Name , issueBefore .Index , token )
91
+ urlStr := fmt .Sprintf ("/api/v1/repos/%s/%s/issues/%d?token=%s" , owner .Name , repoBefore .Name , issueBefore .Index , token )
88
92
req := NewRequestWithJSON (t , "PATCH" , urlStr , api.EditIssueOption {
89
93
State : & issueState ,
90
94
RemoveDeadline : & removeDeadline ,
@@ -99,6 +103,7 @@ func TestAPIEditIssue(t *testing.T) {
99
103
DecodeJSON (t , resp , & apiIssue )
100
104
101
105
issueAfter := models .AssertExistsAndLoadBean (t , & models.Issue {ID : 10 }).(* models.Issue )
106
+ repoAfter := models .AssertExistsAndLoadBean (t , & models.Repository {ID : issueBefore .RepoID }).(* models.Repository )
102
107
103
108
// check deleted user
104
109
assert .Equal (t , int64 (500 ), issueAfter .PosterID )
@@ -107,6 +112,9 @@ func TestAPIEditIssue(t *testing.T) {
107
112
assert .Equal (t , int64 (- 1 ), issueBefore .PosterID )
108
113
assert .Equal (t , int64 (- 1 ), apiIssue .Poster .ID )
109
114
115
+ // check repo change
116
+ assert .Equal (t , repoBefore .NumClosedIssues + 1 , repoAfter .NumClosedIssues )
117
+
110
118
// API response
111
119
assert .Equal (t , api .StateClosed , apiIssue .State )
112
120
assert .Equal (t , milestone , apiIssue .Milestone .ID )
0 commit comments