@@ -73,37 +73,46 @@ func (user *User) CheckForConsistency(t *testing.T) {
73
73
assertCount (t , & Team {OrgID : user .ID }, user .NumTeams )
74
74
assertCount (t , & Follow {UserID : user .ID }, user .NumFollowing )
75
75
assertCount (t , & Follow {FollowID : user .ID }, user .NumFollowers )
76
+ if user .Type != UserTypeOrganization {
77
+ assert .EqualValues (t , 0 , user .NumMembers )
78
+ assert .EqualValues (t , 0 , user .NumTeams )
79
+ }
76
80
}
77
81
78
82
func (repo * Repository ) CheckForConsistency (t * testing.T ) {
79
83
assertCount (t , & Star {RepoID : repo .ID }, repo .NumStars )
80
84
assertCount (t , & Watch {RepoID : repo .ID }, repo .NumWatches )
81
- assertCount (t , & Issue {RepoID : repo .ID }, repo .NumIssues )
82
85
assertCount (t , & Milestone {RepoID : repo .ID }, repo .NumMilestones )
83
86
assertCount (t , & Repository {ForkID : repo .ID }, repo .NumForks )
84
87
if repo .IsFork {
85
88
AssertExistsAndLoadBean (t , & Repository {ID : repo .ForkID })
86
89
}
87
90
88
- actual := getCount (t , x .Where ("is_closed=1" ), & Issue {RepoID : repo .ID })
91
+ actual := getCount (t , x .Where ("is_pull=?" , false ), & Issue {RepoID : repo .ID })
92
+ assert .EqualValues (t , repo .NumIssues , actual ,
93
+ "Unexpected number of issues for repo %+v" , repo )
94
+
95
+ actual = getCount (t , x .Where ("is_pull=? AND is_closed=?" , false , true ), & Issue {RepoID : repo .ID })
89
96
assert .EqualValues (t , repo .NumClosedIssues , actual ,
90
97
"Unexpected number of closed issues for repo %+v" , repo )
91
98
92
- actual = getCount (t , x .Where ("is_pull=1" ), & Issue {RepoID : repo .ID })
99
+ actual = getCount (t , x .Where ("is_pull=?" , true ), & Issue {RepoID : repo .ID })
93
100
assert .EqualValues (t , repo .NumPulls , actual ,
94
101
"Unexpected number of pulls for repo %+v" , repo )
95
102
96
- actual = getCount (t , x .Where ("is_pull=1 AND is_closed=1" ), & Issue {RepoID : repo .ID })
103
+ actual = getCount (t , x .Where ("is_pull=? AND is_closed=?" , true , true ), & Issue {RepoID : repo .ID })
97
104
assert .EqualValues (t , repo .NumClosedPulls , actual ,
98
105
"Unexpected number of closed pulls for repo %+v" , repo )
99
106
100
- actual = getCount (t , x .Where ("is_closed=1" ), & Milestone {RepoID : repo .ID })
107
+ actual = getCount (t , x .Where ("is_closed=?" , true ), & Milestone {RepoID : repo .ID })
101
108
assert .EqualValues (t , repo .NumClosedMilestones , actual ,
102
109
"Unexpected number of closed milestones for repo %+v" , repo )
103
110
}
104
111
105
112
func (issue * Issue ) CheckForConsistency (t * testing.T ) {
106
- assertCount (t , & Comment {IssueID : issue .ID }, issue .NumComments )
113
+ actual := getCount (t , x .Where ("type=?" , CommentTypeComment ), & Comment {IssueID : issue .ID })
114
+ assert .EqualValues (t , issue .NumComments , actual ,
115
+ "Unexpected number of comments for issue %+v" , issue )
107
116
if issue .IsPull {
108
117
pr := AssertExistsAndLoadBean (t , & PullRequest {IssueID : issue .ID }).(* PullRequest )
109
118
assert .EqualValues (t , pr .Index , issue .Index )
@@ -119,7 +128,7 @@ func (pr *PullRequest) CheckForConsistency(t *testing.T) {
119
128
func (milestone * Milestone ) CheckForConsistency (t * testing.T ) {
120
129
assertCount (t , & Issue {MilestoneID : milestone .ID }, milestone .NumIssues )
121
130
122
- actual := getCount (t , x .Where ("is_closed=1" ), & Issue {MilestoneID : milestone .ID })
131
+ actual := getCount (t , x .Where ("is_closed=?" , true ), & Issue {MilestoneID : milestone .ID })
123
132
assert .EqualValues (t , milestone .NumClosedIssues , actual ,
124
133
"Unexpected number of closed issues for milestone %+v" , milestone )
125
134
}
@@ -137,7 +146,7 @@ func (label *Label) CheckForConsistency(t *testing.T) {
137
146
138
147
expected := int64 (0 )
139
148
if len (issueIDs ) > 0 {
140
- expected = getCount (t , x .In ("id" , issueIDs ).Where ("is_closed=1" ), & Issue {})
149
+ expected = getCount (t , x .In ("id" , issueIDs ).Where ("is_closed=?" , true ), & Issue {})
141
150
}
142
151
assert .EqualValues (t , expected , label .NumClosedIssues ,
143
152
"Unexpected number of closed issues for label %+v" , label )
0 commit comments