(t *testing.T)
| 1625 | } |
| 1626 | |
| 1627 | func Test_fillPlaceholders(t *testing.T) { |
| 1628 | type args struct { |
| 1629 | value string |
| 1630 | opts *ApiOptions |
| 1631 | } |
| 1632 | tests := []struct { |
| 1633 | name string |
| 1634 | args args |
| 1635 | repoOverride bool |
| 1636 | want string |
| 1637 | wantErr bool |
| 1638 | }{ |
| 1639 | { |
| 1640 | name: "no changes", |
| 1641 | args: args{ |
| 1642 | value: "repos/owner/repo/releases", |
| 1643 | opts: &ApiOptions{ |
| 1644 | BaseRepo: nil, |
| 1645 | }, |
| 1646 | }, |
| 1647 | want: "repos/owner/repo/releases", |
| 1648 | wantErr: false, |
| 1649 | }, |
| 1650 | { |
| 1651 | name: "has substitutes (colon)", |
| 1652 | args: args{ |
| 1653 | value: "repos/:owner/:repo/releases", |
| 1654 | opts: &ApiOptions{ |
| 1655 | BaseRepo: func() (ghrepo.Interface, error) { |
| 1656 | return ghrepo.New("hubot", "robot-uprising"), nil |
| 1657 | }, |
| 1658 | }, |
| 1659 | }, |
| 1660 | want: "repos/hubot/robot-uprising/releases", |
| 1661 | wantErr: false, |
| 1662 | }, |
| 1663 | { |
| 1664 | name: "has branch placeholder (colon)", |
| 1665 | args: args{ |
| 1666 | value: "repos/owner/repo/branches/:branch/protection/required_status_checks", |
| 1667 | opts: &ApiOptions{ |
| 1668 | BaseRepo: nil, |
| 1669 | Branch: func() (string, error) { |
| 1670 | return "trunk", nil |
| 1671 | }, |
| 1672 | }, |
| 1673 | }, |
| 1674 | want: "repos/owner/repo/branches/trunk/protection/required_status_checks", |
| 1675 | wantErr: false, |
| 1676 | }, |
| 1677 | { |
| 1678 | name: "has branch placeholder and git is in detached head (colon)", |
| 1679 | args: args{ |
| 1680 | value: "repos/:owner/:repo/branches/:branch", |
| 1681 | opts: &ApiOptions{ |
| 1682 | BaseRepo: func() (ghrepo.Interface, error) { |
| 1683 | return ghrepo.New("hubot", "robot-uprising"), nil |
| 1684 | }, |
nothing calls this directly
no test coverage detected