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