mirror of
https://github.com/go-gitea/gitea
synced 2025-01-03 02:56:00 +01:00
968c04c7da
Backport #30556 by @lunny Fix #22419 Only comments with types `CommentTypeComment` and `CommentTypeReview` will be counted as conversations of the pull request. `CommentTypeReview` was missed in the previous implementation. Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
39 lines
1.1 KiB
Go
39 lines
1.1 KiB
Go
// Copyright 2017 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package models
|
|
|
|
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"
|
|
)
|
|
|
|
func TestCheckRepoStats(t *testing.T) {
|
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
|
assert.NoError(t, CheckRepoStats(db.DefaultContext))
|
|
}
|
|
|
|
func TestDoctorUserStarNum(t *testing.T) {
|
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
|
|
|
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)
|
|
}
|