gitea源码

repo_test.go 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2017 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package models
  4. import (
  5. "testing"
  6. issues_model "code.gitea.io/gitea/models/issues"
  7. "code.gitea.io/gitea/models/unittest"
  8. "github.com/stretchr/testify/assert"
  9. )
  10. func TestCheckRepoStats(t *testing.T) {
  11. assert.NoError(t, unittest.PrepareTestDatabase())
  12. assert.NoError(t, CheckRepoStats(t.Context()))
  13. }
  14. func TestDoctorUserStarNum(t *testing.T) {
  15. assert.NoError(t, unittest.PrepareTestDatabase())
  16. assert.NoError(t, DoctorUserStarNum(t.Context()))
  17. }
  18. func Test_repoStatsCorrectIssueNumComments(t *testing.T) {
  19. assert.NoError(t, unittest.PrepareTestDatabase())
  20. issue2 := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 2})
  21. assert.NotNil(t, issue2)
  22. assert.Equal(t, 0, issue2.NumComments) // the fixture data is wrong, but we don't fix it here
  23. assert.NoError(t, repoStatsCorrectIssueNumComments(t.Context(), 2))
  24. // reload the issue
  25. issue2 = unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 2})
  26. assert.Equal(t, 1, issue2.NumComments)
  27. }