From 75a3496bf19c9144d1dc73327bf7c3dd4c795946 Mon Sep 17 00:00:00 2001 From: Corey Johnson Date: Mon, 18 Nov 2019 11:05:43 -0800 Subject: [PATCH] Test flags --- command/issue_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/command/issue_test.go b/command/issue_test.go index be93304b6..09a55609f 100644 --- a/command/issue_test.go +++ b/command/issue_test.go @@ -68,6 +68,31 @@ func TestIssueList(t *testing.T) { } } +func TestIssueList_withFlags(t *testing.T) { + http := initFakeHTTP() + + http.StubResponse(200, bytes.NewBufferString(`{"data": {}}`)) // Since we are testing that the flags are passed, we don't care about the response + + _, err := test.RunCommand(RootCmd, "issue list -a probablyCher -l web,bug -s open") + if err != nil { + t.Errorf("error running command `issue list`: %v", err) + } + + bodyBytes, _ := ioutil.ReadAll(http.Requests[0].Body) + reqBody := struct { + Variables struct { + Assignee string + Labels []string + States []string + } + }{} + json.Unmarshal(bodyBytes, &reqBody) + + eq(t, reqBody.Variables.Assignee, "probablyCher") + eq(t, reqBody.Variables.Labels, []string{"web", "bug"}) + eq(t, reqBody.Variables.States, []string{"OPEN"}) +} + func TestIssueView(t *testing.T) { initBlankContext("OWNER/REPO", "master") http := initFakeHTTP()