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

Function TestClientUnsetRemoteResolution

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

Source from the content-addressed store, hash-verified

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