MCPcopy Create free account
hub / github.com/cli/cli / TestParseRemotes

Function TestParseRemotes

git/client_test.go:187–221  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

185}
186
187func TestParseRemotes(t *testing.T) {
188 remoteList := []string{
189 "mona\tgit@github.com:monalisa/myfork.git (fetch)",
190 "origin\thttps://github.com/monalisa/octo-cat.git (fetch)",
191 "origin\thttps://github.com/monalisa/octo-cat-push.git (push)",
192 "upstream\thttps://example.com/nowhere.git (fetch)",
193 "upstream\thttps://github.com/hubot/tools (push)",
194 "zardoz\thttps://example.com/zed.git (push)",
195 "koke\tgit://github.com/koke/grit.git (fetch)",
196 "koke\tgit://github.com/koke/grit.git (push)",
197 }
198
199 r := parseRemotes(remoteList)
200 assert.Equal(t, 5, len(r))
201
202 assert.Equal(t, "mona", r[0].Name)
203 assert.Equal(t, "ssh://git@github.com/monalisa/myfork.git", r[0].FetchURL.String())
204 assert.Nil(t, r[0].PushURL)
205
206 assert.Equal(t, "origin", r[1].Name)
207 assert.Equal(t, "/monalisa/octo-cat.git", r[1].FetchURL.Path)
208 assert.Equal(t, "/monalisa/octo-cat-push.git", r[1].PushURL.Path)
209
210 assert.Equal(t, "upstream", r[2].Name)
211 assert.Equal(t, "example.com", r[2].FetchURL.Host)
212 assert.Equal(t, "github.com", r[2].PushURL.Host)
213
214 assert.Equal(t, "zardoz", r[3].Name)
215 assert.Nil(t, r[3].FetchURL)
216 assert.Equal(t, "https://example.com/zed.git", r[3].PushURL.String())
217
218 assert.Equal(t, "koke", r[4].Name)
219 assert.Equal(t, "/koke/grit.git", r[4].FetchURL.Path)
220 assert.Equal(t, "/koke/grit.git", r[4].PushURL.Path)
221}
222
223func TestClientUpdateRemoteURL(t *testing.T) {
224 tests := []struct {

Callers

nothing calls this directly

Calls 3

parseRemotesFunction · 0.85
EqualMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected