Have --state=closed include merged PRs

Since we currently offer no way of querying PRs by combining multiple
states with an OR, the best way to handle the `closed` state is to match
what the web UI is doing; that is to include merged PRs.
This commit is contained in:
Mislav Marohnić 2020-02-20 13:53:44 +01:00
parent 57eb1d1d45
commit 861b231344
2 changed files with 25 additions and 1 deletions

View file

@ -163,7 +163,7 @@ func prList(cmd *cobra.Command, args []string) error {
case "open":
graphqlState = []string{"OPEN"}
case "closed":
graphqlState = []string{"CLOSED"}
graphqlState = []string{"CLOSED", "MERGED"}
case "merged":
graphqlState = []string{"MERGED"}
case "all":

View file

@ -210,6 +210,30 @@ No pull requests match your search
eq(t, reqBody.Variables.Labels, []string{"one", "two", "three"})
}
func TestPRList_filteringClosed(t *testing.T) {
initBlankContext("OWNER/REPO", "master")
http := initFakeHTTP()
http.StubRepoResponse("OWNER", "REPO")
respBody := bytes.NewBufferString(`{ "data": {} }`)
http.StubResponse(200, respBody)
_, err := RunCommand(prListCmd, `pr list -s closed`)
if err != nil {
t.Fatal(err)
}
bodyBytes, _ := ioutil.ReadAll(http.Requests[1].Body)
reqBody := struct {
Variables struct {
State []string
}
}{}
json.Unmarshal(bodyBytes, &reqBody)
eq(t, reqBody.Variables.State, []string{"CLOSED", "MERGED"})
}
func TestPRList_filteringAssignee(t *testing.T) {
initBlankContext("OWNER/REPO", "master")
http := initFakeHTTP()