From f09b05e628ea8a0af0c9c501154a1c3b40c64128 Mon Sep 17 00:00:00 2001 From: vilmibm Date: Tue, 21 Jan 2020 15:47:36 -0600 Subject: [PATCH] test for disabled issues --- command/issue_test.go | 45 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/command/issue_test.go b/command/issue_test.go index e9f616f68..532c3cc35 100644 --- a/command/issue_test.go +++ b/command/issue_test.go @@ -202,6 +202,13 @@ func TestIssueView(t *testing.T) { initBlankContext("OWNER/REPO", "master") http := initFakeHTTP() + http.StubResponse(200, bytes.NewBufferString(` + { "data": { "repository": { + "id": "REPOID", + "hasIssuesEnabled": true + } } } + `)) + http.StubResponse(200, bytes.NewBufferString(` { "data": { "repository": { "issue": { "number": 123, @@ -235,6 +242,13 @@ func TestIssueView_preview(t *testing.T) { initBlankContext("OWNER/REPO", "master") http := initFakeHTTP() + http.StubResponse(200, bytes.NewBufferString(` + { "data": { "repository": { + "id": "REPOID", + "hasIssuesEnabled": true + } } } + `)) + http.StubResponse(200, bytes.NewBufferString(` { "data": { "repository": { "issue": { "number": 123, @@ -280,6 +294,13 @@ func TestIssueView_notFound(t *testing.T) { initBlankContext("OWNER/REPO", "master") http := initFakeHTTP() + http.StubResponse(200, bytes.NewBufferString(` + { "data": { "repository": { + "id": "REPOID", + "hasIssuesEnabled": true + } } } + `)) + http.StubResponse(200, bytes.NewBufferString(` { "errors": [ { "message": "Could not resolve to an Issue with the number of 9999." } @@ -303,10 +324,34 @@ func TestIssueView_notFound(t *testing.T) { } } +func TestIssueView_disabledIssues(t *testing.T) { + initBlankContext("OWNER/REPO", "master") + http := initFakeHTTP() + + http.StubResponse(200, bytes.NewBufferString(` + { "data": { "repository": { + "id": "REPOID", + "hasIssuesEnabled": false + } } } + `)) + + _, err := RunCommand(issueViewCmd, `issue view 6666`) + if err == nil || err.Error() != "the 'OWNER/REPO' repository has disabled issues" { + t.Errorf("error running command `issue view`: %v", err) + } +} + func TestIssueView_urlArg(t *testing.T) { initBlankContext("OWNER/REPO", "master") http := initFakeHTTP() + http.StubResponse(200, bytes.NewBufferString(` + { "data": { "repository": { + "id": "REPOID", + "hasIssuesEnabled": true + } } } + `)) + http.StubResponse(200, bytes.NewBufferString(` { "data": { "repository": { "issue": { "number": 123,