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