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.

37 lines
1.1 KiB

  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. assert.NoError(t, err)
  18. code, err := bareRepo1.GetCodeActivityStats(timeFrom, "")
  19. assert.NoError(t, err)
  20. assert.NotNil(t, code)
  21. assert.EqualValues(t, 9, code.CommitCount)
  22. assert.EqualValues(t, 3, code.AuthorCount)
  23. assert.EqualValues(t, 9, code.CommitCountInAllBranches)
  24. assert.EqualValues(t, 10, code.Additions)
  25. assert.EqualValues(t, 1, code.Deletions)
  26. assert.Len(t, code.Authors, 3)
  27. assert.EqualValues(t, "tris.git@shoddynet.org", code.Authors[1].Email)
  28. assert.EqualValues(t, 3, code.Authors[1].Commits)
  29. assert.EqualValues(t, 5, code.Authors[0].Commits)
  30. }