(t *testing.T)
| 1523 | } |
| 1524 | |
| 1525 | func Test_fillPlaceholders(t *testing.T) { |
| 1526 | type args struct { |
| 1527 | value string |
| 1528 | opts *ApiOptions |
| 1529 | } |
| 1530 | tests := []struct { |
| 1531 | name string |
| 1532 | args args |
| 1533 | repoOverride bool |
| 1534 | want string |
| 1535 | wantErr bool |
| 1536 | }{ |
| 1537 | { |
| 1538 | name: "no changes", |
| 1539 | args: args{ |
| 1540 | value: "repos/owner/repo/releases", |
| 1541 | opts: &ApiOptions{ |
| 1542 | BaseRepo: nil, |
| 1543 | }, |
| 1544 | }, |
| 1545 | want: "repos/owner/repo/releases", |
| 1546 | wantErr: false, |
| 1547 | }, |
| 1548 | { |
| 1549 | name: "has substitutes (colon)", |
| 1550 | args: args{ |
| 1551 | value: "repos/:owner/:repo/releases", |
| 1552 | opts: &ApiOptions{ |
| 1553 | BaseRepo: func() (ghrepo.Interface, error) { |
| 1554 | return ghrepo.New("hubot", "robot-uprising"), nil |
| 1555 | }, |
| 1556 | }, |
| 1557 | }, |
| 1558 | want: "repos/hubot/robot-uprising/releases", |
| 1559 | wantErr: false, |
| 1560 | }, |
| 1561 | { |
| 1562 | name: "has branch placeholder (colon)", |
| 1563 | args: args{ |
| 1564 | value: "repos/owner/repo/branches/:branch/protection/required_status_checks", |
| 1565 | opts: &ApiOptions{ |
| 1566 | BaseRepo: nil, |
| 1567 | Branch: func() (string, error) { |
| 1568 | return "trunk", nil |
| 1569 | }, |
| 1570 | }, |
| 1571 | }, |
| 1572 | want: "repos/owner/repo/branches/trunk/protection/required_status_checks", |
| 1573 | wantErr: false, |
| 1574 | }, |
| 1575 | { |
| 1576 | name: "has branch placeholder and git is in detached head (colon)", |
| 1577 | args: args{ |
| 1578 | value: "repos/:owner/:repo/branches/:branch", |
| 1579 | opts: &ApiOptions{ |
| 1580 | BaseRepo: func() (ghrepo.Interface, error) { |
| 1581 | return ghrepo.New("hubot", "robot-uprising"), nil |
| 1582 | }, |
nothing calls this directly
no test coverage detected