MCPcopy
hub / github.com/cli/cli / Test_editRun_crossHostRelationshipRefs

Function Test_editRun_crossHostRelationshipRefs

pkg/cmd/issue/edit/edit_test.go:1463–1533  ·  view source on GitHub ↗

Test_editRun_crossHostRelationshipRefs verifies that every relationship flag rejects a cross-host issue URL with the same clear error. Lives as its own table rather than additional cases in Test_editRun because each case shares identical setup and asserts the same error, varying only in which input

(t *testing.T)

Source from the content-addressed store, hash-verified

1461// case shares identical setup and asserts the same error, varying only in
1462// which input field carries the cross-host URL.
1463func Test_editRun_crossHostRelationshipRefs(t *testing.T) {
1464 const crossHostURL = "https://example.com/OWNER/REPO/issues/9"
1465
1466 // Each case exercises one relationship-bearing flag with a cross-host
1467 // URL. ResolveIssueRef should short-circuit before any GraphQL request,
1468 // and the per-issue failure must surface to stderr.
1469 tests := []struct {
1470 name string
1471 input *EditOptions
1472 }{
1473 {
1474 name: "set parent",
1475 input: &EditOptions{Parent: crossHostURL},
1476 },
1477 {
1478 name: "add sub-issue",
1479 input: &EditOptions{AddSubIssues: []string{crossHostURL}},
1480 },
1481 {
1482 name: "remove sub-issue",
1483 input: &EditOptions{RemoveSubIssues: []string{crossHostURL}},
1484 },
1485 {
1486 name: "add blocked-by",
1487 input: &EditOptions{AddBlockedBy: []string{crossHostURL}},
1488 },
1489 {
1490 name: "remove blocked-by",
1491 input: &EditOptions{RemoveBlockedBy: []string{crossHostURL}},
1492 },
1493 {
1494 name: "add blocking",
1495 input: &EditOptions{AddBlocking: []string{crossHostURL}},
1496 },
1497 {
1498 name: "remove blocking",
1499 input: &EditOptions{RemoveBlocking: []string{crossHostURL}},
1500 },
1501 }
1502
1503 for _, tt := range tests {
1504 t.Run(tt.name, func(t *testing.T) {
1505 ios, _, _, stderr := iostreams.Test()
1506 ios.SetStdoutTTY(true)
1507
1508 reg := &httpmock.Registry{}
1509 defer reg.Verify(t)
1510 mockIssueGet(t, reg)
1511 // No IssueNodeID stub on purpose: the cross-host guard must
1512 // short-circuit before any resolution request goes out.
1513
1514 tt.input.Detector = &fd.EnabledDetectorMock{}
1515 tt.input.IssueNumbers = []int{123}
1516 tt.input.Interactive = false
1517 tt.input.FetchOptions = func(_ *api.Client, _ ghrepo.Interface, _ *prShared.Editable, _ gh.ProjectsV1Support) error {
1518 return nil
1519 }
1520 tt.input.IO = ios

Callers

nothing calls this directly

Calls 9

VerifyMethod · 0.95
TestFunction · 0.92
NewFunction · 0.92
mockIssueGetFunction · 0.85
SetStdoutTTYMethod · 0.80
editRunFunction · 0.70
RunMethod · 0.65
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected