Fix issue comment number (#30556)
This commit is contained in:
parent
a87168869a
commit
a54cc05d2a
5 changed files with 89 additions and 19 deletions
|
@ -7,6 +7,7 @@ import (
|
|||
"testing"
|
||||
|
||||
"code.gitea.io/gitea/models/db"
|
||||
issues_model "code.gitea.io/gitea/models/issues"
|
||||
"code.gitea.io/gitea/models/unittest"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -22,3 +23,16 @@ func TestDoctorUserStarNum(t *testing.T) {
|
|||
|
||||
assert.NoError(t, DoctorUserStarNum(db.DefaultContext))
|
||||
}
|
||||
|
||||
func Test_repoStatsCorrectIssueNumComments(t *testing.T) {
|
||||
assert.NoError(t, unittest.PrepareTestDatabase())
|
||||
|
||||
issue2 := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 2})
|
||||
assert.NotNil(t, issue2)
|
||||
assert.EqualValues(t, 0, issue2.NumComments) // the fixture data is wrong, but we don't fix it here
|
||||
|
||||
assert.NoError(t, repoStatsCorrectIssueNumComments(db.DefaultContext, 2))
|
||||
// reload the issue
|
||||
issue2 = unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 2})
|
||||
assert.EqualValues(t, 1, issue2.NumComments)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue