31 lines
954 B
Go
31 lines
954 B
Go
package git
|
|
|
|
import "testing"
|
|
|
|
func Test_parseRemotes(t *testing.T) {
|
|
remoteList := []string{
|
|
"mona\tgit@github.com:monalisa/myfork.git (fetch)",
|
|
"origin\thttps://github.com/monalisa/octo-cat.git (fetch)",
|
|
"origin\thttps://github.com/monalisa/octo-cat-push.git (push)",
|
|
"upstream\thttps://example.com/nowhere.git (fetch)",
|
|
"upstream\thttps://github.com/hubot/tools (push)",
|
|
"zardoz\thttps://example.com/zed.git (push)",
|
|
}
|
|
r := parseRemotes(remoteList)
|
|
eq(t, len(r), 4)
|
|
|
|
eq(t, r[0].Name, "mona")
|
|
eq(t, r[0].FetchURL.String(), "ssh://git@github.com/monalisa/myfork.git")
|
|
if r[0].PushURL != nil {
|
|
t.Errorf("expected no PushURL, got %q", r[0].PushURL)
|
|
}
|
|
eq(t, r[1].Name, "origin")
|
|
eq(t, r[1].FetchURL.Path, "/monalisa/octo-cat.git")
|
|
eq(t, r[1].PushURL.Path, "/monalisa/octo-cat-push.git")
|
|
|
|
eq(t, r[2].Name, "upstream")
|
|
eq(t, r[2].FetchURL.Host, "example.com")
|
|
eq(t, r[2].PushURL.Host, "github.com")
|
|
|
|
eq(t, r[3].Name, "zardoz")
|
|
}
|