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.1KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright 2019 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 git
  5. import (
  6. "path/filepath"
  7. "testing"
  8. "time"
  9. "github.com/stretchr/testify/assert"
  10. )
  11. func TestRepository_GetCodeActivityStats(t *testing.T) {
  12. bareRepo1Path := filepath.Join(testReposDir, "repo1_bare")
  13. bareRepo1, err := OpenRepository(bareRepo1Path)
  14. assert.NoError(t, err)
  15. defer bareRepo1.Close()
  16. timeFrom, err := time.Parse(time.RFC3339, "2016-01-01T00:00:00+00:00")
  17. code, err := bareRepo1.GetCodeActivityStats(timeFrom, "")
  18. assert.NoError(t, err)
  19. assert.NotNil(t, code)
  20. assert.EqualValues(t, 9, code.CommitCount)
  21. assert.EqualValues(t, 3, code.AuthorCount)
  22. assert.EqualValues(t, 9, 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.Contains(t, code.Authors, "tris.git@shoddynet.org")
  27. assert.EqualValues(t, 3, code.Authors["tris.git@shoddynet.org"])
  28. assert.EqualValues(t, 5, code.Authors[""])
  29. }