(t *testing.T)
| 1629 | } |
| 1630 | |
| 1631 | func TestClientFetch(t *testing.T) { |
| 1632 | tests := []struct { |
| 1633 | name string |
| 1634 | mods []CommandModifier |
| 1635 | commands mockedCommands |
| 1636 | wantErrorMsg string |
| 1637 | }{ |
| 1638 | { |
| 1639 | name: "fetch", |
| 1640 | commands: map[args]commandResult{ |
| 1641 | `path/to/git -c credential.helper= -c credential.helper=!"gh" auth git-credential fetch origin trunk`: { |
| 1642 | ExitStatus: 0, |
| 1643 | }, |
| 1644 | }, |
| 1645 | }, |
| 1646 | { |
| 1647 | name: "accepts command modifiers", |
| 1648 | mods: []CommandModifier{WithRepoDir("/path/to/repo")}, |
| 1649 | commands: map[args]commandResult{ |
| 1650 | `path/to/git -C /path/to/repo -c credential.helper= -c credential.helper=!"gh" auth git-credential fetch origin trunk`: { |
| 1651 | ExitStatus: 0, |
| 1652 | }, |
| 1653 | }, |
| 1654 | }, |
| 1655 | { |
| 1656 | name: "git error on fetch", |
| 1657 | commands: map[args]commandResult{ |
| 1658 | `path/to/git -c credential.helper= -c credential.helper=!"gh" auth git-credential fetch origin trunk`: { |
| 1659 | ExitStatus: 1, |
| 1660 | Stderr: "fetch error message", |
| 1661 | }, |
| 1662 | }, |
| 1663 | wantErrorMsg: "failed to run git: fetch error message", |
| 1664 | }, |
| 1665 | } |
| 1666 | |
| 1667 | for _, tt := range tests { |
| 1668 | t.Run(tt.name, func(t *testing.T) { |
| 1669 | cmdCtx := createMockedCommandContext(t, tt.commands) |
| 1670 | client := Client{ |
| 1671 | GitPath: "path/to/git", |
| 1672 | commandContext: cmdCtx, |
| 1673 | } |
| 1674 | err := client.Fetch(context.Background(), "origin", "trunk", tt.mods...) |
| 1675 | if tt.wantErrorMsg == "" { |
| 1676 | require.NoError(t, err) |
| 1677 | } else { |
| 1678 | require.EqualError(t, err, tt.wantErrorMsg) |
| 1679 | } |
| 1680 | }) |
| 1681 | } |
| 1682 | } |
| 1683 | |
| 1684 | func TestClientPull(t *testing.T) { |
| 1685 | tests := []struct { |
nothing calls this directly
no test coverage detected