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