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