forked from cli/cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremote_test.go
More file actions
42 lines (36 loc) · 1.17 KB
/
remote_test.go
File metadata and controls
42 lines (36 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package git
import (
"reflect"
"testing"
)
// TODO: extract assertion helpers into a shared package
func eq(t *testing.T, got interface{}, expected interface{}) {
t.Helper()
if !reflect.DeepEqual(got, expected) {
t.Errorf("expected: %v, got: %v", expected, got)
}
}
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")
}