2017-12-02 19:53:19 -02:00
|
|
|
package release
|
2017-01-14 19:12:20 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2017-10-15 17:46:21 -02:00
|
|
|
"github.com/goreleaser/goreleaser/internal/testlib"
|
2017-01-14 19:12:20 +01:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestRepoName(t *testing.T) {
|
2017-10-15 17:46:21 -02:00
|
|
|
_, back := testlib.Mktmp(t)
|
|
|
|
defer back()
|
|
|
|
testlib.GitInit(t)
|
|
|
|
testlib.GitRemoteAdd(t, "git@github.com:goreleaser/goreleaser.git")
|
2017-03-22 21:01:29 -03:00
|
|
|
repo, err := remoteRepo()
|
2017-09-26 19:24:49 -03:00
|
|
|
assert.NoError(t, err)
|
|
|
|
assert.Equal(t, "goreleaser/goreleaser", repo.String())
|
2017-01-14 19:12:20 +01:00
|
|
|
}
|
|
|
|
|
2018-02-20 18:21:20 -03: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 19:12:20 +01:00
|
|
|
}
|