2018-10-12 14:06:03 +02:00
|
|
|
package commands
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2018-10-15 11:00:19 +02:00
|
|
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
2018-10-12 14:06:03 +02:00
|
|
|
)
|
|
|
|
|
2018-11-30 02:47:14 +02:00
|
|
|
// TestGetRepoInfoFromURL is a function.
|
2018-10-12 14:06:03 +02:00
|
|
|
func TestGetRepoInfoFromURL(t *testing.T) {
|
|
|
|
type scenario struct {
|
|
|
|
testName string
|
|
|
|
repoURL string
|
|
|
|
test func(*RepoInformation)
|
|
|
|
}
|
|
|
|
|
|
|
|
scenarios := []scenario{
|
|
|
|
{
|
|
|
|
"Returns repository information for git remote url",
|
|
|
|
"git@github.com:petersmith/super_calculator",
|
|
|
|
func(repoInfo *RepoInformation) {
|
|
|
|
assert.EqualValues(t, repoInfo.Owner, "petersmith")
|
|
|
|
assert.EqualValues(t, repoInfo.Repository, "super_calculator")
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"Returns repository information for http remote url",
|
|
|
|
"https://my_username@bitbucket.org/johndoe/social_network.git",
|
|
|
|
func(repoInfo *RepoInformation) {
|
|
|
|
assert.EqualValues(t, repoInfo.Owner, "johndoe")
|
|
|
|
assert.EqualValues(t, repoInfo.Repository, "social_network")
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, s := range scenarios {
|
|
|
|
t.Run(s.testName, func(t *testing.T) {
|
|
|
|
s.test(getRepoInfoFromURL(s.repoURL))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|