您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

indexer_test.go 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright 2020 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package stats
  5. import (
  6. "path/filepath"
  7. "testing"
  8. "time"
  9. "code.gitea.io/gitea/models"
  10. "code.gitea.io/gitea/models/unittest"
  11. "code.gitea.io/gitea/modules/setting"
  12. "gopkg.in/ini.v1"
  13. "github.com/stretchr/testify/assert"
  14. )
  15. func TestMain(m *testing.M) {
  16. unittest.MainTest(m, filepath.Join("..", "..", ".."))
  17. }
  18. func TestRepoStatsIndex(t *testing.T) {
  19. assert.NoError(t, unittest.PrepareTestDatabase())
  20. setting.Cfg = ini.Empty()
  21. setting.NewQueueService()
  22. err := Init()
  23. assert.NoError(t, err)
  24. time.Sleep(5 * time.Second)
  25. repo, err := models.GetRepositoryByID(1)
  26. assert.NoError(t, err)
  27. status, err := repo.GetIndexerStatus(models.RepoIndexerTypeStats)
  28. assert.NoError(t, err)
  29. assert.Equal(t, "65f1bf27bc3bf70f64657658635e66094edbcb4d", status.CommitSha)
  30. langs, err := repo.GetTopLanguageStats(5)
  31. assert.NoError(t, err)
  32. assert.Empty(t, langs)
  33. }