MCPcopy
hub / github.com/cli/cli / TestClientUpdateRemoteURL

Function TestClientUpdateRemoteURL

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

Source from the content-addressed store, hash-verified

219}
220
221func TestClientUpdateRemoteURL(t *testing.T) {
222 tests := []struct {
223 name string
224 cmdExitStatus int
225 cmdStdout string
226 cmdStderr string
227 wantCmdArgs string
228 wantErrorMsg string
229 }{
230 {
231 name: "update remote url",
232 wantCmdArgs: `path/to/git remote set-url test https://test.com`,
233 },
234 {
235 name: "git error",
236 cmdExitStatus: 1,
237 cmdStderr: "git error message",
238 wantCmdArgs: `path/to/git remote set-url test https://test.com`,
239 wantErrorMsg: "failed to run git: git error message",
240 },
241 }
242 for _, tt := range tests {
243 t.Run(tt.name, func(t *testing.T) {
244 cmd, cmdCtx := createCommandContext(t, tt.cmdExitStatus, tt.cmdStdout, tt.cmdStderr)
245 client := Client{
246 GitPath: "path/to/git",
247 commandContext: cmdCtx,
248 }
249 err := client.UpdateRemoteURL(context.Background(), "test", "https://test.com")
250 assert.Equal(t, tt.wantCmdArgs, strings.Join(cmd.Args[3:], " "))
251 if tt.wantErrorMsg == "" {
252 assert.NoError(t, err)
253 } else {
254 assert.EqualError(t, err, tt.wantErrorMsg)
255 }
256 })
257 }
258}
259
260func TestClientSetRemoteResolution(t *testing.T) {
261 tests := []struct {

Callers

nothing calls this directly

Calls 5

UpdateRemoteURLMethod · 0.95
createCommandContextFunction · 0.85
EqualMethod · 0.80
JoinMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected