Files

38 lines
1.0 KiB
Go
Raw Permalink Normal View History

// Copyright 2017 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package models
import (
"testing"
2024-12-30 14:35:46 -08:00
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(t.Context()))
}
func TestDoctorUserStarNum(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
assert.NoError(t, DoctorUserStarNum(t.Context()))
}
2024-12-30 14:35:46 -08: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)
2025-03-31 07:53:48 +02:00
assert.Equal(t, 0, issue2.NumComments) // the fixture data is wrong, but we don't fix it here
2024-12-30 14:35:46 -08:00
assert.NoError(t, repoStatsCorrectIssueNumComments(t.Context(), 2))
2024-12-30 14:35:46 -08:00
// reload the issue
issue2 = unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 2})
2025-03-31 07:53:48 +02:00
assert.Equal(t, 1, issue2.NumComments)
2024-12-30 14:35:46 -08:00
}