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