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

Function TestClientPull

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

Source from the content-addressed store, hash-verified

1682}
1683
1684func TestClientPull(t *testing.T) {
1685 tests := []struct {
1686 name string
1687 mods []CommandModifier
1688 commands mockedCommands
1689 wantErrorMsg string
1690 }{
1691 {
1692 name: "pull",
1693 commands: map[args]commandResult{
1694 `path/to/git -c credential.helper= -c credential.helper=!"gh" auth git-credential pull --ff-only origin trunk`: {
1695 ExitStatus: 0,
1696 },
1697 },
1698 },
1699 {
1700 name: "accepts command modifiers",
1701 mods: []CommandModifier{WithRepoDir("/path/to/repo")},
1702 commands: map[args]commandResult{
1703 `path/to/git -C /path/to/repo -c credential.helper= -c credential.helper=!"gh" auth git-credential pull --ff-only origin trunk`: {
1704 ExitStatus: 0,
1705 },
1706 },
1707 },
1708 {
1709 name: "git error on pull",
1710 commands: map[args]commandResult{
1711 `path/to/git -c credential.helper= -c credential.helper=!"gh" auth git-credential pull --ff-only origin trunk`: {
1712 ExitStatus: 1,
1713 Stderr: "pull error message",
1714 },
1715 },
1716 wantErrorMsg: "failed to run git: pull error message",
1717 },
1718 }
1719
1720 for _, tt := range tests {
1721 t.Run(tt.name, func(t *testing.T) {
1722 cmdCtx := createMockedCommandContext(t, tt.commands)
1723 client := Client{
1724 GitPath: "path/to/git",
1725 commandContext: cmdCtx,
1726 }
1727 err := client.Pull(context.Background(), "origin", "trunk", tt.mods...)
1728 if tt.wantErrorMsg == "" {
1729 require.NoError(t, err)
1730 } else {
1731 require.EqualError(t, err, tt.wantErrorMsg)
1732 }
1733 })
1734 }
1735}
1736
1737func TestClientPush(t *testing.T) {
1738 tests := []struct {

Callers

nothing calls this directly

Calls 4

PullMethod · 0.95
WithRepoDirFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected