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