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

1234567891011121314151617181920212223242526272829303132333435
  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. timeFrom, err := time.Parse(time.RFC3339, "2016-01-01T00:00:00+00:00")
  16. code, err := bareRepo1.GetCodeActivityStats(timeFrom, "")
  17. assert.NoError(t, err)
  18. assert.NotNil(t, code)
  19. assert.EqualValues(t, 8, code.CommitCount)
  20. assert.EqualValues(t, 2, code.AuthorCount)
  21. assert.EqualValues(t, 8, code.CommitCountInAllBranches)
  22. assert.EqualValues(t, 10, code.Additions)
  23. assert.EqualValues(t, 1, code.Deletions)
  24. assert.Len(t, code.Authors, 2)
  25. assert.Contains(t, code.Authors, "tris.git@shoddynet.org")
  26. assert.EqualValues(t, 3, code.Authors["tris.git@shoddynet.org"])
  27. assert.EqualValues(t, 5, code.Authors[""])
  28. }