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

Function TestClientRemotes_no_resolved_remote

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

Source from the content-addressed store, hash-verified

150}
151
152func TestClientRemotes_no_resolved_remote(t *testing.T) {
153 IsolateConfig(t)
154 tempDir := t.TempDir()
155 initRepo(t, tempDir)
156 gitDir := filepath.Join(tempDir, ".git")
157 remoteFile := filepath.Join(gitDir, "config")
158 remotes := `
159[remote "origin"]
160 url = git@example.com:monalisa/origin.git
161[remote "test"]
162 url = git://github.com/hubot/test.git
163[remote "upstream"]
164 url = https://github.com/monalisa/upstream.git
165[remote "github"]
166 url = git@github.com:hubot/github.git
167`
168 f, err := os.OpenFile(remoteFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0755)
169 assert.NoError(t, err)
170 _, err = f.Write([]byte(remotes))
171 assert.NoError(t, err)
172 err = f.Close()
173 assert.NoError(t, err)
174 client := Client{
175 RepoDir: tempDir,
176 }
177 rs, err := client.Remotes(context.Background())
178 assert.NoError(t, err)
179 assert.Equal(t, 4, len(rs))
180 assert.Equal(t, "upstream", rs[0].Name)
181 assert.Equal(t, "github", rs[1].Name)
182 assert.Equal(t, "origin", rs[2].Name)
183 assert.Equal(t, "", rs[2].Resolved)
184 assert.Equal(t, "test", rs[3].Name)
185}
186
187func TestParseRemotes(t *testing.T) {
188 remoteList := []string{

Callers

nothing calls this directly

Calls 7

RemotesMethod · 0.95
IsolateConfigFunction · 0.85
initRepoFunction · 0.85
JoinMethod · 0.80
EqualMethod · 0.80
WriteMethod · 0.65
CloseMethod · 0.65

Tested by

no test coverage detected