MCPcopy Create free account
hub / github.com/cli/cli / Test_editRun_crossHostRelationshipRefs

Function Test_editRun_crossHostRelationshipRefs

pkg/cmd/issue/edit/edit_test.go:2029–2099  ·  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

2027// case shares identical setup and asserts the same error, varying only in
2028// which input field carries the cross-host URL.
2029func Test_editRun_crossHostRelationshipRefs(t *testing.T) {
2030 const crossHostURL = "https://example.com/OWNER/REPO/issues/9"
2031
2032 // Each case exercises one relationship-bearing flag with a cross-host
2033 // URL. ResolveIssueRef should short-circuit before any GraphQL request,
2034 // and the per-issue failure must surface to stderr.
2035 tests := []struct {
2036 name string
2037 input *EditOptions
2038 }{
2039 {
2040 name: "set parent",
2041 input: &EditOptions{Parent: crossHostURL},
2042 },
2043 {
2044 name: "add sub-issue",
2045 input: &EditOptions{AddSubIssues: []string{crossHostURL}},
2046 },
2047 {
2048 name: "remove sub-issue",
2049 input: &EditOptions{RemoveSubIssues: []string{crossHostURL}},
2050 },
2051 {
2052 name: "add blocked-by",
2053 input: &EditOptions{AddBlockedBy: []string{crossHostURL}},
2054 },
2055 {
2056 name: "remove blocked-by",
2057 input: &EditOptions{RemoveBlockedBy: []string{crossHostURL}},
2058 },
2059 {
2060 name: "add blocking",
2061 input: &EditOptions{AddBlocking: []string{crossHostURL}},
2062 },
2063 {
2064 name: "remove blocking",
2065 input: &EditOptions{RemoveBlocking: []string{crossHostURL}},
2066 },
2067 }
2068
2069 for _, tt := range tests {
2070 t.Run(tt.name, func(t *testing.T) {
2071 ios, _, _, stderr := iostreams.Test()
2072 ios.SetStdoutTTY(true)
2073
2074 reg := &httpmock.Registry{}
2075 defer reg.Verify(t)
2076 mockIssueGet(t, reg)
2077 // No IssueNodeID stub on purpose: the cross-host guard must
2078 // short-circuit before any resolution request goes out.
2079
2080 tt.input.Detector = &fd.EnabledDetectorMock{}
2081 tt.input.IssueNumbers = []int{123}
2082 tt.input.Interactive = false
2083 tt.input.FetchOptions = func(_ *api.Client, _ ghrepo.Interface, _ *prShared.Editable, _ gh.ProjectsV1Support) error {
2084 return nil
2085 }
2086 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
StringMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected