mirror of
https://github.com/go-gitea/gitea.git
synced 2024-10-29 08:17:31 -04:00
31 lines
783 B
Go
31 lines
783 B
Go
|
// Copyright 2020 The Gitea Authors. All rights reserved.
|
||
|
// Use of this source code is governed by a MIT-style
|
||
|
// license that can be found in the LICENSE file.
|
||
|
|
||
|
package issue
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"code.gitea.io/gitea/models"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestGetRefEndNamesAndURLs(t *testing.T) {
|
||
|
issues := []*models.Issue{
|
||
|
{ID: 1, Ref: "refs/heads/branch1"},
|
||
|
{ID: 2, Ref: "refs/tags/tag1"},
|
||
|
{ID: 3, Ref: "c0ffee"},
|
||
|
}
|
||
|
repoLink := "/foo/bar"
|
||
|
|
||
|
endNames, urls := GetRefEndNamesAndURLs(issues, repoLink)
|
||
|
assert.EqualValues(t, map[int64]string{1: "branch1", 2: "tag1", 3: "c0ffee"}, endNames)
|
||
|
assert.EqualValues(t, map[int64]string{
|
||
|
1: repoLink + "/src/branch/branch1",
|
||
|
2: repoLink + "/src/tag/tag1",
|
||
|
3: repoLink + "/src/commit/c0ffee",
|
||
|
}, urls)
|
||
|
}
|