You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

repo_stats_test.go 1.0KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright 2019 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package git
  4. import (
  5. "path/filepath"
  6. "testing"
  7. "time"
  8. "github.com/stretchr/testify/assert"
  9. )
  10. func TestRepository_GetCodeActivityStats(t *testing.T) {
  11. bareRepo1Path := filepath.Join(testReposDir, "repo1_bare")
  12. bareRepo1, err := openRepositoryWithDefaultContext(bareRepo1Path)
  13. assert.NoError(t, err)
  14. defer bareRepo1.Close()
  15. timeFrom, err := time.Parse(time.RFC3339, "2016-01-01T00:00:00+00:00")
  16. assert.NoError(t, err)
  17. code, err := bareRepo1.GetCodeActivityStats(timeFrom, "")
  18. assert.NoError(t, err)
  19. assert.NotNil(t, code)
  20. assert.EqualValues(t, 10, code.CommitCount)
  21. assert.EqualValues(t, 3, code.AuthorCount)
  22. assert.EqualValues(t, 10, code.CommitCountInAllBranches)
  23. assert.EqualValues(t, 10, code.Additions)
  24. assert.EqualValues(t, 1, code.Deletions)
  25. assert.Len(t, code.Authors, 3)
  26. assert.EqualValues(t, "tris.git@shoddynet.org", code.Authors[1].Email)
  27. assert.EqualValues(t, 3, code.Authors[1].Commits)
  28. assert.EqualValues(t, 5, code.Authors[0].Commits)
  29. }