MCPcopy
hub / github.com/cli/cli / TestClientUnsetRemoteResolution

Function TestClientUnsetRemoteResolution

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

Source from the content-addressed store, hash-verified

1547}
1548
1549func TestClientUnsetRemoteResolution(t *testing.T) {
1550 tests := []struct {
1551 name string
1552 cmdExitStatus int
1553 cmdStdout string
1554 cmdStderr string
1555 wantCmdArgs string
1556 wantErrorMsg string
1557 }{
1558 {
1559 name: "unset remote resolution",
1560 wantCmdArgs: `path/to/git config --unset remote.origin.gh-resolved`,
1561 },
1562 {
1563 name: "git error",
1564 cmdExitStatus: 1,
1565 cmdStderr: "git error message",
1566 wantCmdArgs: `path/to/git config --unset remote.origin.gh-resolved`,
1567 wantErrorMsg: "failed to run git: git error message",
1568 },
1569 }
1570 for _, tt := range tests {
1571 t.Run(tt.name, func(t *testing.T) {
1572 cmd, cmdCtx := createCommandContext(t, tt.cmdExitStatus, tt.cmdStdout, tt.cmdStderr)
1573 client := Client{
1574 GitPath: "path/to/git",
1575 commandContext: cmdCtx,
1576 }
1577 err := client.UnsetRemoteResolution(context.Background(), "origin")
1578 assert.Equal(t, tt.wantCmdArgs, strings.Join(cmd.Args[3:], " "))
1579 if tt.wantErrorMsg == "" {
1580 assert.NoError(t, err)
1581 } else {
1582 assert.EqualError(t, err, tt.wantErrorMsg)
1583 }
1584 })
1585 }
1586}
1587
1588func TestClientSetRemoteBranches(t *testing.T) {
1589 tests := []struct {

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected