MCPcopy
hub / github.com/cli/cli / TestParseRemotes

Function TestParseRemotes

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

parseRemotesFunction · 0.85
EqualMethod · 0.80
StringMethod · 0.45

Tested by

no test coverage detected