mirror of
https://github.com/github/gh-stack.git
synced 2026-09-14 20:26:28 +08:00
29 lines
702 B
Go
29 lines
702 B
Go
package github
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestPRURL(t *testing.T) {
|
|
tests := []struct {
|
|
name string
|
|
host string
|
|
owner string
|
|
repo string
|
|
number int
|
|
want string
|
|
}{
|
|
{"github.com", "github.com", "owner", "repo", 42, "https://github.com/owner/repo/pull/42"},
|
|
{"GHES host", "ghes.example.com", "myorg", "myrepo", 99, "https://ghes.example.com/myorg/myrepo/pull/99"},
|
|
{"empty host defaults to github.com", "", "owner", "repo", 1, "https://github.com/owner/repo/pull/1"},
|
|
}
|
|
for _, tt := range tests {
|
|
t.Run(tt.name, func(t *testing.T) {
|
|
got := PRURL(tt.host, tt.owner, tt.repo, tt.number)
|
|
assert.Equal(t, tt.want, got)
|
|
})
|
|
}
|
|
}
|