Merge pull request #159 from github/no-issues-assigned-notice

Fix displaying "There are no issues assigned to you" notice
This commit is contained in:
Nate Smith 2019-12-16 10:35:58 -06:00 committed by GitHub
commit 3dcadd73bd
2 changed files with 34 additions and 2 deletions

View file

@ -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)

View file

@ -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()