55 "net/http"
66 "testing"
77
8- fd "github.com/cli/cli/v2/internal/featuredetection"
98 "github.com/cli/cli/v2/internal/ghrepo"
109 "github.com/cli/cli/v2/pkg/cmd/issue/argparsetest"
1110 "github.com/cli/cli/v2/pkg/cmdutil"
@@ -16,15 +15,6 @@ import (
1615 "github.com/stretchr/testify/require"
1716)
1817
19- type issueFeaturesDetectorMock struct {
20- fd.EnabledDetectorMock
21- issueFeatures fd.IssueFeatures
22- }
23-
24- func (md * issueFeaturesDetectorMock ) IssueFeatures () (fd.IssueFeatures , error ) {
25- return md .issueFeatures , nil
26- }
27-
2818func TestNewCmdClose (t * testing.T ) {
2919 // Test shared parsing of issue number / URL.
3020 argparsetest .TestArgParsing (t , NewCmdClose )
@@ -194,7 +184,6 @@ func TestCloseRun(t *testing.T) {
194184 opts : & CloseOptions {
195185 IssueNumber : 13 ,
196186 Reason : "not planned" ,
197- Detector : & fd.EnabledDetectorMock {},
198187 },
199188 httpStubs : func (reg * httpmock.Registry ) {
200189 reg .Register (
@@ -222,7 +211,6 @@ func TestCloseRun(t *testing.T) {
222211 opts : & CloseOptions {
223212 IssueNumber : 13 ,
224213 Reason : "duplicate" ,
225- Detector : & fd.EnabledDetectorMock {},
226214 },
227215 httpStubs : func (reg * httpmock.Registry ) {
228216 reg .Register (
@@ -250,7 +238,6 @@ func TestCloseRun(t *testing.T) {
250238 opts : & CloseOptions {
251239 IssueNumber : 13 ,
252240 DuplicateOf : "99" ,
253- Detector : & fd.EnabledDetectorMock {},
254241 },
255242 httpStubs : func (reg * httpmock.Registry ) {
256243 reg .Register (
@@ -282,71 +269,6 @@ func TestCloseRun(t *testing.T) {
282269 },
283270 wantStderr : "✓ Closed issue OWNER/REPO#13 (The title of the issue)\n " ,
284271 },
285- {
286- name : "close issue with duplicate reason when duplicate is not supported" ,
287- opts : & CloseOptions {
288- IssueNumber : 13 ,
289- Reason : "duplicate" ,
290- Detector : & issueFeaturesDetectorMock {
291- issueFeatures : fd.IssueFeatures {
292- StateReason : true ,
293- StateReasonDuplicate : false ,
294- },
295- },
296- },
297- httpStubs : func (reg * httpmock.Registry ) {
298- reg .Register (
299- httpmock .GraphQL (`query IssueByNumber\b` ),
300- httpmock .StringResponse (`
301- { "data": { "repository": {
302- "hasIssuesEnabled": true,
303- "issue": { "id": "THE-ID", "number": 13, "title": "The title of the issue"}
304- } } }` ),
305- )
306- reg .Register (
307- httpmock .GraphQL (`mutation IssueClose\b` ),
308- httpmock .GraphQLMutation (`{"id": "THE-ID"}` ,
309- func (inputs map [string ]interface {}) {
310- assert .Equal (t , 1 , len (inputs ))
311- assert .Equal (t , "THE-ID" , inputs ["issueId" ])
312- }),
313- )
314- },
315- wantStderr : "✓ Closed issue OWNER/REPO#13 (The title of the issue)\n " ,
316- },
317- {
318- name : "close issue as duplicate when duplicate is not supported" ,
319- opts : & CloseOptions {
320- IssueNumber : 13 ,
321- DuplicateOf : "99" ,
322- Detector : & issueFeaturesDetectorMock {
323- issueFeatures : fd.IssueFeatures {
324- StateReason : true ,
325- StateReasonDuplicate : false ,
326- },
327- },
328- },
329- httpStubs : func (reg * httpmock.Registry ) {
330- reg .Register (
331- httpmock .GraphQL (`query IssueByNumber\b` ),
332- httpmock .StringResponse (`
333- { "data": { "repository": {
334- "hasIssuesEnabled": true,
335- "issue": { "id": "THE-ID", "number": 13, "title": "The title of the issue"}
336- } } }` ),
337- )
338- reg .Register (
339- httpmock .GraphQL (`query IssueByNumber\b` ),
340- httpmock .StringResponse (`
341- { "data": { "repository": {
342- "hasIssuesEnabled": true,
343- "issue": { "id": "DUPLICATE-ID", "number": 99}
344- } } }` ),
345- )
346- },
347- wantErr : true ,
348- errMsg : "closing as duplicate is not supported on github.com" ,
349- },
350272 {
351273 name : "duplicate of cannot point to same issue" ,
352274 opts : & CloseOptions {
@@ -412,33 +334,6 @@ func TestCloseRun(t *testing.T) {
412334 wantErr : true ,
413335 errMsg : "invalid value for `--duplicate-of`: invalid issue format: \" not-an-issue\" " ,
414336 },
415- {
416- name : "close issue with reason when reason is not supported" ,
417- opts : & CloseOptions {
418- IssueNumber : 13 ,
419- Reason : "not planned" ,
420- Detector : & fd.DisabledDetectorMock {},
421- },
422- httpStubs : func (reg * httpmock.Registry ) {
423- reg .Register (
424- httpmock .GraphQL (`query IssueByNumber\b` ),
425- httpmock .StringResponse (`
426- { "data": { "repository": {
427- "hasIssuesEnabled": true,
428- "issue": { "id": "THE-ID", "number": 13, "title": "The title of the issue"}
429- } } }` ),
430- )
431- reg .Register (
432- httpmock .GraphQL (`mutation IssueClose\b` ),
433- httpmock .GraphQLMutation (`{"id": "THE-ID"}` ,
434- func (inputs map [string ]interface {}) {
435- assert .Equal (t , 1 , len (inputs ))
436- assert .Equal (t , "THE-ID" , inputs ["issueId" ])
437- }),
438- )
439- },
440- wantStderr : "✓ Closed issue OWNER/REPO#13 (The title of the issue)\n " ,
441- },
442337 {
443338 name : "issue already closed" ,
444339 opts : & CloseOptions {
0 commit comments