Skip to content

Commit bd9b3b9

Browse files
committed
Add tests for issue status/list/create on repos with issues disabled
1 parent aeb7f33 commit bd9b3b9

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

command/issue_test.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,22 @@ Issues opened by you
7373
}
7474
}
7575

76+
func TestIssueStatus_disabledIssues(t *testing.T) {
77+
initBlankContext("OWNER/REPO", "master")
78+
http := initFakeHTTP()
79+
80+
http.StubResponse(200, bytes.NewBufferString(`
81+
{ "data": { "repository": {
82+
"hasIssuesEnabled": false
83+
} } }
84+
`))
85+
86+
_, err := RunCommand(issueStatusCmd, "issue status")
87+
if err == nil || err.Error() != "the 'OWNER/REPO' repository has disabled issues" {
88+
t.Errorf("error running command `issue status`: %v", err)
89+
}
90+
}
91+
7692
func TestIssueList(t *testing.T) {
7793
initBlankContext("OWNER/REPO", "master")
7894
http := initFakeHTTP()
@@ -101,6 +117,7 @@ func TestIssueList(t *testing.T) {
101117
}
102118

103119
func TestIssueList_withFlags(t *testing.T) {
120+
initBlankContext("OWNER/REPO", "master")
104121
http := initFakeHTTP()
105122

106123
http.StubResponse(200, bytes.NewBufferString(`
@@ -133,6 +150,22 @@ func TestIssueList_withFlags(t *testing.T) {
133150
eq(t, reqBody.Variables.States, []string{"OPEN"})
134151
}
135152

153+
func TestIssueList_disabledIssues(t *testing.T) {
154+
initBlankContext("OWNER/REPO", "master")
155+
http := initFakeHTTP()
156+
157+
http.StubResponse(200, bytes.NewBufferString(`
158+
{ "data": { "repository": {
159+
"hasIssuesEnabled": false
160+
} } }
161+
`))
162+
163+
_, err := RunCommand(issueListCmd, "issue list")
164+
if err == nil || err.Error() != "the 'OWNER/REPO' repository has disabled issues" {
165+
t.Errorf("error running command `issue list`: %v", err)
166+
}
167+
}
168+
136169
func TestIssueView(t *testing.T) {
137170
initBlankContext("OWNER/REPO", "master")
138171
http := initFakeHTTP()
@@ -265,6 +298,23 @@ func TestIssueCreate(t *testing.T) {
265298
eq(t, output.String(), "https://github.com/OWNER/REPO/issues/12\n")
266299
}
267300

301+
func TestIssueCreate_disabledIssues(t *testing.T) {
302+
initBlankContext("OWNER/REPO", "master")
303+
http := initFakeHTTP()
304+
305+
http.StubResponse(200, bytes.NewBufferString(`
306+
{ "data": { "repository": {
307+
"id": "REPOID",
308+
"hasIssuesEnabled": false
309+
} } }
310+
`))
311+
312+
_, err := RunCommand(issueCreateCmd, `issue create -t heres -b johnny`)
313+
if err == nil || err.Error() != "the 'OWNER/REPO' repository has disabled issues" {
314+
t.Errorf("error running command `issue create`: %v", err)
315+
}
316+
}
317+
268318
func TestIssueCreate_web(t *testing.T) {
269319
initBlankContext("OWNER/REPO", "master")
270320
initFakeHTTP()

0 commit comments

Comments
 (0)