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