MCPcopy
hub / github.com/cli/cli / TestClientSetRemoteResolution

Function TestClientSetRemoteResolution

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

Source from the content-addressed store, hash-verified

258}
259
260func TestClientSetRemoteResolution(t *testing.T) {
261 tests := []struct {
262 name string
263 cmdExitStatus int
264 cmdStdout string
265 cmdStderr string
266 wantCmdArgs string
267 wantErrorMsg string
268 }{
269 {
270 name: "set remote resolution",
271 wantCmdArgs: `path/to/git config --add remote.origin.gh-resolved base`,
272 },
273 {
274 name: "git error",
275 cmdExitStatus: 1,
276 cmdStderr: "git error message",
277 wantCmdArgs: `path/to/git config --add remote.origin.gh-resolved base`,
278 wantErrorMsg: "failed to run git: git error message",
279 },
280 }
281 for _, tt := range tests {
282 t.Run(tt.name, func(t *testing.T) {
283 cmd, cmdCtx := createCommandContext(t, tt.cmdExitStatus, tt.cmdStdout, tt.cmdStderr)
284 client := Client{
285 GitPath: "path/to/git",
286 commandContext: cmdCtx,
287 }
288 err := client.SetRemoteResolution(context.Background(), "origin", "base")
289 assert.Equal(t, tt.wantCmdArgs, strings.Join(cmd.Args[3:], " "))
290 if tt.wantErrorMsg == "" {
291 assert.NoError(t, err)
292 } else {
293 assert.EqualError(t, err, tt.wantErrorMsg)
294 }
295 })
296 }
297}
298
299func TestClientCurrentBranch(t *testing.T) {
300 tests := []struct {

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected