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_branch_test.go 917B

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright 2018 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. "github.com/stretchr/testify/assert"
  9. )
  10. func TestRepository_GetBranches(t *testing.T) {
  11. bareRepo1Path := filepath.Join(testReposDir, "repo1_bare")
  12. bareRepo1, err := OpenRepository(bareRepo1Path)
  13. assert.NoError(t, err)
  14. branches, err := bareRepo1.GetBranches()
  15. assert.NoError(t, err)
  16. assert.Len(t, branches, 3)
  17. assert.ElementsMatch(t, []string{"branch1", "branch2", "master"}, branches)
  18. }
  19. func BenchmarkRepository_GetBranches(b *testing.B) {
  20. bareRepo1Path := filepath.Join(testReposDir, "repo1_bare")
  21. bareRepo1, err := OpenRepository(bareRepo1Path)
  22. if err != nil {
  23. b.Fatal(err)
  24. }
  25. for i := 0; i < b.N; i++ {
  26. _, err := bareRepo1.GetBranches()
  27. if err != nil {
  28. b.Fatal(err)
  29. }
  30. }
  31. }