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