(t *testing.T)
| 1731 | } |
| 1732 | |
| 1733 | func TestClientPush(t *testing.T) { |
| 1734 | tests := []struct { |
| 1735 | name string |
| 1736 | mods []CommandModifier |
| 1737 | commands mockedCommands |
| 1738 | wantErrorMsg string |
| 1739 | }{ |
| 1740 | { |
| 1741 | name: "push", |
| 1742 | commands: map[args]commandResult{ |
| 1743 | `path/to/git -c credential.helper= -c credential.helper=!"gh" auth git-credential push --set-upstream origin trunk`: { |
| 1744 | ExitStatus: 0, |
| 1745 | }, |
| 1746 | }, |
| 1747 | }, |
| 1748 | { |
| 1749 | name: "accepts command modifiers", |
| 1750 | mods: []CommandModifier{WithRepoDir("/path/to/repo")}, |
| 1751 | commands: map[args]commandResult{ |
| 1752 | `path/to/git -C /path/to/repo -c credential.helper= -c credential.helper=!"gh" auth git-credential push --set-upstream origin trunk`: { |
| 1753 | ExitStatus: 0, |
| 1754 | }, |
| 1755 | }, |
| 1756 | }, |
| 1757 | { |
| 1758 | name: "git error on push", |
| 1759 | commands: map[args]commandResult{ |
| 1760 | `path/to/git -c credential.helper= -c credential.helper=!"gh" auth git-credential push --set-upstream origin trunk`: { |
| 1761 | ExitStatus: 1, |
| 1762 | Stderr: "push error message", |
| 1763 | }, |
| 1764 | }, |
| 1765 | wantErrorMsg: "failed to run git: push error message", |
| 1766 | }, |
| 1767 | } |
| 1768 | |
| 1769 | for _, tt := range tests { |
| 1770 | t.Run(tt.name, func(t *testing.T) { |
| 1771 | cmdCtx := createMockedCommandContext(t, tt.commands) |
| 1772 | client := Client{ |
| 1773 | GitPath: "path/to/git", |
| 1774 | commandContext: cmdCtx, |
| 1775 | } |
| 1776 | err := client.Push(context.Background(), "origin", "trunk", tt.mods...) |
| 1777 | if tt.wantErrorMsg == "" { |
| 1778 | require.NoError(t, err) |
| 1779 | } else { |
| 1780 | require.EqualError(t, err, tt.wantErrorMsg) |
| 1781 | } |
| 1782 | }) |
| 1783 | } |
| 1784 | } |
| 1785 | |
| 1786 | func TestClientClone(t *testing.T) { |
| 1787 | tests := []struct { |
nothing calls this directly
no test coverage detected