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

Function TestDevelopRun

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

Source from the content-addressed store, hash-verified

187}
188
189func TestDevelopRun(t *testing.T) {
190 featureEnabledPayload := `{"data":{"LinkedBranch":{"fields":[{"name":"id"},{"name":"ref"}]}}}`
191 featureDisabledPayload := `{"data":{"LinkedBranch":null}}`
192 unsafeTargetDir := t.TempDir()
193 unsafeTarget := filepath.Join(unsafeTargetDir, "worktree-link")
194 require.NoError(t, os.Symlink(unsafeTargetDir, unsafeTarget))
195 nonEmptyTarget := t.TempDir()
196 require.NoError(t, os.WriteFile(filepath.Join(nonEmptyTarget, "file"), []byte("x"), 0o644))
197
198 tests := []struct {
199 name string
200 opts *DevelopOptions
201 cmdStubs func(*run.CommandStubber)
202 runStubs func(*run.CommandStubber)
203 remotes map[string]string
204 httpStubs func(*httpmock.Registry, *testing.T)
205 expectedOut string
206 expectedErrOut string
207 wantErr string
208 wantErrContains string
209 tty bool
210 }{
211 {
212 name: "returns an error when the feature is not supported by the API",
213 opts: &DevelopOptions{
214 IssueNumber: 42,
215 List: true,
216 },
217 httpStubs: func(reg *httpmock.Registry, t *testing.T) {
218 reg.Register(
219 httpmock.GraphQL(`query IssueByNumber\b`),
220 httpmock.StringResponse(`{"data":{"repository":{"hasIssuesEnabled":true,"issue":{"id":"SOMEID","number":42}}}}`),
221 )
222 reg.Register(
223 httpmock.GraphQL(`query LinkedBranchFeature\b`),
224 httpmock.StringResponse(featureDisabledPayload),
225 )
226 },
227 wantErr: "the `gh issue develop` command is not currently available",
228 },
229 {
230 name: "list branches for an issue",
231 opts: &DevelopOptions{
232 IssueNumber: 42,
233 List: true,
234 },
235 httpStubs: func(reg *httpmock.Registry, t *testing.T) {
236 reg.Register(
237 httpmock.GraphQL(`query IssueByNumber\b`),
238 httpmock.StringResponse(`{"data":{"repository":{"hasIssuesEnabled":true,"issue":{"id":"SOMEID","number":42}}}}`),
239 )
240 reg.Register(
241 httpmock.GraphQL(`query LinkedBranchFeature\b`),
242 httpmock.StringResponse(featureEnabledPayload),
243 )
244 reg.Register(
245 httpmock.GraphQL(`query ListLinkedBranches\b`),
246 httpmock.GraphQLQuery(`

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
JoinMethod · 0.80

Tested by

no test coverage detected