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

Function TestClientRemotes

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

Source from the content-addressed store, hash-verified

110}
111
112func TestClientRemotes(t *testing.T) {
113 IsolateConfig(t)
114 tempDir := t.TempDir()
115 initRepo(t, tempDir)
116 gitDir := filepath.Join(tempDir, ".git")
117 remoteFile := filepath.Join(gitDir, "config")
118 remotes := `
119[remote "origin"]
120 url = git@example.com:monalisa/origin.git
121[remote "test"]
122 url = git://github.com/hubot/test.git
123 gh-resolved = other
124[remote "upstream"]
125 url = https://github.com/monalisa/upstream.git
126 gh-resolved = base
127[remote "github"]
128 url = git@github.com:hubot/github.git
129`
130 f, err := os.OpenFile(remoteFile, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0755)
131 assert.NoError(t, err)
132 _, err = f.Write([]byte(remotes))
133 assert.NoError(t, err)
134 err = f.Close()
135 assert.NoError(t, err)
136 client := Client{
137 RepoDir: tempDir,
138 }
139 rs, err := client.Remotes(context.Background())
140 assert.NoError(t, err)
141 assert.Equal(t, 4, len(rs))
142 assert.Equal(t, "upstream", rs[0].Name)
143 assert.Equal(t, "base", rs[0].Resolved)
144 assert.Equal(t, "github", rs[1].Name)
145 assert.Equal(t, "", rs[1].Resolved)
146 assert.Equal(t, "origin", rs[2].Name)
147 assert.Equal(t, "", rs[2].Resolved)
148 assert.Equal(t, "test", rs[3].Name)
149 assert.Equal(t, "other", rs[3].Resolved)
150}
151
152func TestClientRemotes_no_resolved_remote(t *testing.T) {
153 IsolateConfig(t)

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