diff --git a/command/issue.go b/command/issue.go index ec4f7b188..15c0a7177 100644 --- a/command/issue.go +++ b/command/issue.go @@ -169,10 +169,10 @@ func issueStatus(cmd *cobra.Command, args []string) error { out := colorableOut(cmd) printHeader(out, "Issues assigned to you") - if issuePayload.Assigned != nil { + if len(issuePayload.Assigned) > 0 { printIssues(out, " ", issuePayload.Assigned...) } else { - message := fmt.Sprintf(" There are no issues assgined to you") + message := fmt.Sprintf(" There are no issues assigned to you") printMessage(out, message) } fmt.Fprintln(out) diff --git a/command/issue_test.go b/command/issue_test.go index b5f8f0272..5b6e4c3e3 100644 --- a/command/issue_test.go +++ b/command/issue_test.go @@ -40,6 +40,38 @@ func TestIssueStatus(t *testing.T) { } } +func TestIssueStatus_blankSlate(t *testing.T) { + initBlankContext("OWNER/REPO", "master") + http := initFakeHTTP() + + http.StubResponse(200, bytes.NewBufferString(` + { "data": { + "assigned": { "issues": { "nodes": [] } }, + "mentioned": { "issues": { "nodes": [] } }, + "authored": { "issues": { "nodes": [] } } + } } + `)) + + output, err := RunCommand(issueStatusCmd, "issue status") + if err != nil { + t.Errorf("error running command `issue status`: %v", err) + } + + expectedOutput := `Issues assigned to you + There are no issues assigned to you + +Issues mentioning you + There are no issues mentioning you + +Issues opened by you + There are no issues opened by you + +` + if output != expectedOutput { + t.Errorf("expected %q, got %q", expectedOutput, output) + } +} + func TestIssueList(t *testing.T) { initBlankContext("OWNER/REPO", "master") http := initFakeHTTP()