2017-02-06 10:18:36 -05:00
|
|
|
// Copyright 2017 The Gitea Authors. All rights reserved.
|
2022-11-27 13:20:29 -05:00
|
|
|
// SPDX-License-Identifier: MIT
|
2017-02-06 10:18:36 -05:00
|
|
|
|
|
|
|
package models
|
2016-04-22 18:28:08 -04:00
|
|
|
|
|
|
|
import (
|
2016-07-09 01:22:28 -04:00
|
|
|
"testing"
|
2016-04-22 18:28:08 -04:00
|
|
|
|
2021-09-19 07:49:59 -04:00
|
|
|
"code.gitea.io/gitea/models/db"
|
2024-12-30 17:35:46 -05:00
|
|
|
issues_model "code.gitea.io/gitea/models/issues"
|
2021-11-12 09:36:47 -05:00
|
|
|
"code.gitea.io/gitea/models/unittest"
|
2017-02-06 10:18:36 -05:00
|
|
|
|
2017-06-06 09:53:16 -04:00
|
|
|
"github.com/stretchr/testify/assert"
|
2016-04-22 18:28:08 -04:00
|
|
|
)
|
|
|
|
|
2022-01-17 13:31:58 -05:00
|
|
|
func TestCheckRepoStats(t *testing.T) {
|
|
|
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
|
|
|
assert.NoError(t, CheckRepoStats(db.DefaultContext))
|
|
|
|
}
|
|
|
|
|
2020-07-07 15:16:34 -04:00
|
|
|
func TestDoctorUserStarNum(t *testing.T) {
|
2021-11-12 09:36:47 -05:00
|
|
|
assert.NoError(t, unittest.PrepareTestDatabase())
|
2020-07-07 15:16:34 -04:00
|
|
|
|
2023-10-11 00:24:07 -04:00
|
|
|
assert.NoError(t, DoctorUserStarNum(db.DefaultContext))
|
2020-07-07 15:16:34 -04:00
|
|
|
}
|
2024-12-30 17:35:46 -05:00
|
|
|
|
|
|
|
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)
|
|
|
|
}
|