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

Function TestClientUnsetRemoteResolution

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

Source from the content-addressed store, hash-verified

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