github.com/abdfnx/gh-api@v0.0.0-20210414084727-f5432eec23b8/git/remote_test.go (about) 1 package git 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/assert" 7 ) 8 9 func Test_parseRemotes(t *testing.T) { 10 remoteList := []string{ 11 "mona\tgit@github.com:monalisa/myfork.git (fetch)", 12 "origin\thttps://github.com/monalisa/octo-cat.git (fetch)", 13 "origin\thttps://github.com/monalisa/octo-cat-push.git (push)", 14 "upstream\thttps://example.com/nowhere.git (fetch)", 15 "upstream\thttps://github.com/hubot/tools (push)", 16 "zardoz\thttps://example.com/zed.git (push)", 17 } 18 r := parseRemotes(remoteList) 19 assert.Equal(t, 4, len(r)) 20 21 assert.Equal(t, "mona", r[0].Name) 22 assert.Equal(t, "ssh://git@github.com/monalisa/myfork.git", r[0].FetchURL.String()) 23 if r[0].PushURL != nil { 24 t.Errorf("expected no PushURL, got %q", r[0].PushURL) 25 } 26 assert.Equal(t, "origin", r[1].Name) 27 assert.Equal(t, "/monalisa/octo-cat.git", r[1].FetchURL.Path) 28 assert.Equal(t, "/monalisa/octo-cat-push.git", r[1].PushURL.Path) 29 30 assert.Equal(t, "upstream", r[2].Name) 31 assert.Equal(t, "example.com", r[2].FetchURL.Host) 32 assert.Equal(t, "github.com", r[2].PushURL.Host) 33 34 assert.Equal(t, "zardoz", r[3].Name) 35 }