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.

issue_test.go 783B

123456789101112131415161718192021222324252627282930
  1. // Copyright 2020 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 issue
  5. import (
  6. "testing"
  7. "code.gitea.io/gitea/models"
  8. "github.com/stretchr/testify/assert"
  9. )
  10. func TestGetRefEndNamesAndURLs(t *testing.T) {
  11. issues := []*models.Issue{
  12. {ID: 1, Ref: "refs/heads/branch1"},
  13. {ID: 2, Ref: "refs/tags/tag1"},
  14. {ID: 3, Ref: "c0ffee"},
  15. }
  16. repoLink := "/foo/bar"
  17. endNames, urls := GetRefEndNamesAndURLs(issues, repoLink)
  18. assert.EqualValues(t, map[int64]string{1: "branch1", 2: "tag1", 3: "c0ffee"}, endNames)
  19. assert.EqualValues(t, map[int64]string{
  20. 1: repoLink + "/src/branch/branch1",
  21. 2: repoLink + "/src/tag/tag1",
  22. 3: repoLink + "/src/commit/c0ffee",
  23. }, urls)
  24. }