MCPcopy
hub / github.com/cli/cli / TestDevelopRun

Function TestDevelopRun

pkg/cmd/issue/develop/develop_test.go:156–769  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

154}
155
156func TestDevelopRun(t *testing.T) {
157 featureEnabledPayload := `{"data":{"LinkedBranch":{"fields":[{"name":"id"},{"name":"ref"}]}}}`
158 featureDisabledPayload := `{"data":{"LinkedBranch":null}}`
159
160 tests := []struct {
161 name string
162 opts *DevelopOptions
163 cmdStubs func(*run.CommandStubber)
164 runStubs func(*run.CommandStubber)
165 remotes map[string]string
166 httpStubs func(*httpmock.Registry, *testing.T)
167 expectedOut string
168 expectedErrOut string
169 wantErr string
170 tty bool
171 }{
172 {
173 name: "returns an error when the feature is not supported by the API",
174 opts: &DevelopOptions{
175 IssueNumber: 42,
176 List: true,
177 },
178 httpStubs: func(reg *httpmock.Registry, t *testing.T) {
179 reg.Register(
180 httpmock.GraphQL(`query IssueByNumber\b`),
181 httpmock.StringResponse(`{"data":{"repository":{"hasIssuesEnabled":true,"issue":{"id":"SOMEID","number":42}}}}`),
182 )
183 reg.Register(
184 httpmock.GraphQL(`query LinkedBranchFeature\b`),
185 httpmock.StringResponse(featureDisabledPayload),
186 )
187 },
188 wantErr: "the `gh issue develop` command is not currently available",
189 },
190 {
191 name: "list branches for an issue",
192 opts: &DevelopOptions{
193 IssueNumber: 42,
194 List: true,
195 },
196 httpStubs: func(reg *httpmock.Registry, t *testing.T) {
197 reg.Register(
198 httpmock.GraphQL(`query IssueByNumber\b`),
199 httpmock.StringResponse(`{"data":{"repository":{"hasIssuesEnabled":true,"issue":{"id":"SOMEID","number":42}}}}`),
200 )
201 reg.Register(
202 httpmock.GraphQL(`query LinkedBranchFeature\b`),
203 httpmock.StringResponse(featureEnabledPayload),
204 )
205 reg.Register(
206 httpmock.GraphQL(`query ListLinkedBranches\b`),
207 httpmock.GraphQLQuery(`
208 {"data":{"repository":{"issue":{"linkedBranches":{"nodes":[{"ref":{"name":"foo","repository":{"url":"https://github.com/OWNER/REPO"}}},{"ref":{"name":"bar","repository":{"url":"https://github.com/OWNER/REPO"}}}]}}}}}
209 `, func(query string, inputs map[string]interface{}) {
210 assert.Equal(t, float64(42), inputs["number"])
211 assert.Equal(t, "OWNER", inputs["owner"])
212 assert.Equal(t, "REPO", inputs["name"])
213 }))

Callers

nothing calls this directly

Calls 15

RegisterMethod · 0.95
VerifyMethod · 0.95
GraphQLFunction · 0.92
StringResponseFunction · 0.92
GraphQLQueryFunction · 0.92
GraphQLMutationFunction · 0.92
NewFunction · 0.92
TestFunction · 0.92
FromFullNameFunction · 0.92
StubFunction · 0.92
developRunFunction · 0.85
EqualMethod · 0.80

Tested by

no test coverage detected