MCPcopy Index your code
hub / github.com/cli/cli / Test_fillPlaceholders

Function Test_fillPlaceholders

pkg/cmd/api/api_test.go:1445–1622  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1443}
1444
1445func Test_fillPlaceholders(t *testing.T) {
1446 type args struct {
1447 value string
1448 opts *ApiOptions
1449 }
1450 tests := []struct {
1451 name string
1452 args args
1453 repoOverride bool
1454 want string
1455 wantErr bool
1456 }{
1457 {
1458 name: "no changes",
1459 args: args{
1460 value: "repos/owner/repo/releases",
1461 opts: &ApiOptions{
1462 BaseRepo: nil,
1463 },
1464 },
1465 want: "repos/owner/repo/releases",
1466 wantErr: false,
1467 },
1468 {
1469 name: "has substitutes (colon)",
1470 args: args{
1471 value: "repos/:owner/:repo/releases",
1472 opts: &ApiOptions{
1473 BaseRepo: func() (ghrepo.Interface, error) {
1474 return ghrepo.New("hubot", "robot-uprising"), nil
1475 },
1476 },
1477 },
1478 want: "repos/hubot/robot-uprising/releases",
1479 wantErr: false,
1480 },
1481 {
1482 name: "has branch placeholder (colon)",
1483 args: args{
1484 value: "repos/owner/repo/branches/:branch/protection/required_status_checks",
1485 opts: &ApiOptions{
1486 BaseRepo: nil,
1487 Branch: func() (string, error) {
1488 return "trunk", nil
1489 },
1490 },
1491 },
1492 want: "repos/owner/repo/branches/trunk/protection/required_status_checks",
1493 wantErr: false,
1494 },
1495 {
1496 name: "has branch placeholder and git is in detached head (colon)",
1497 args: args{
1498 value: "repos/:owner/:repo/branches/:branch",
1499 opts: &ApiOptions{
1500 BaseRepo: func() (ghrepo.Interface, error) {
1501 return ghrepo.New("hubot", "robot-uprising"), nil
1502 },

Callers

nothing calls this directly

Calls 4

NewFunction · 0.92
fillPlaceholdersFunction · 0.85
RunMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected