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

Function TestClientUpdateRemoteURL

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

Source from the content-addressed store, hash-verified

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