2017-12-02 23:53:19 +02:00
|
|
|
package release
|
2017-01-14 20:12:20 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2017-10-15 21:46:21 +02:00
|
|
|
"github.com/goreleaser/goreleaser/internal/testlib"
|
2017-01-14 20:12:20 +02:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestRepoName(t *testing.T) {
|
2017-10-15 21:46:21 +02:00
|
|
|
_, back := testlib.Mktmp(t)
|
|
|
|
defer back()
|
|
|
|
testlib.GitInit(t)
|
|
|
|
testlib.GitRemoteAdd(t, "git@github.com:goreleaser/goreleaser.git")
|
2017-03-23 02:01:29 +02:00
|
|
|
repo, err := remoteRepo()
|
2017-09-27 00:24:49 +02:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, "goreleaser/goreleaser", repo.String())
|
2017-01-14 20:12:20 +02:00
|
|
|
}
|
|
|
|
|
2018-02-20 23:21:20 +02:00
|
|
|
func TestExtractRepoFromURL(t *testing.T) {
|
|
|
|
for _, url := range []string{
|
|
|
|
"git@github.com:goreleaser/goreleaser.git",
|
|
|
|
"git@custom:goreleaser/goreleaser.git",
|
|
|
|
"git@custom:crazy/url/goreleaser/goreleaser.git",
|
|
|
|
"https://github.com/goreleaser/goreleaser.git",
|
|
|
|
"https://github.enterprise.com/goreleaser/goreleaser.git",
|
|
|
|
"https://github.enterprise.com/crazy/url/goreleaser/goreleaser.git",
|
|
|
|
} {
|
|
|
|
t.Run(url, func(t *testing.T) {
|
|
|
|
repo := extractRepoFromURL(url)
|
|
|
|
assert.Equal(t, "goreleaser/goreleaser", repo.String())
|
|
|
|
})
|
|
|
|
}
|
2017-01-14 20:12:20 +02:00
|
|
|
}
|