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

Function TestClientSetRemoteResolution

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

Source from the content-addressed store, hash-verified

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