fix pr filtering

This commit is contained in:
nate smith 2019-11-05 14:48:32 -07:00 committed by Mislav Marohnić
parent 667704d574
commit e3a11c8ffb
2 changed files with 8 additions and 6 deletions

View file

@ -126,14 +126,16 @@ func prList(cmd *cobra.Command, args []string) error {
return err
}
var graphqlState string
var graphqlState []string
switch state {
case "open":
graphqlState = "OPEN"
graphqlState = []string{"OPEN"}
case "closed":
graphqlState = "CLOSED"
graphqlState = []string{"CLOSED"}
case "merged":
graphqlState = []string{"MERGED"}
case "all":
graphqlState = "ALL"
graphqlState = []string{"OPEN", "CLOSED", "MERGED"}
default:
return fmt.Errorf("invalid state: %s", state)
}

View file

@ -107,13 +107,13 @@ func TestPRList_filtering(t *testing.T) {
bodyBytes, _ := ioutil.ReadAll(http.Requests[0].Body)
reqBody := struct {
Variables struct {
State string
State []string
Labels []string
}
}{}
json.Unmarshal(bodyBytes, &reqBody)
eq(t, reqBody.Variables.State, "ALL")
eq(t, reqBody.Variables.State, []string{"OPEN", "CLOSED", "MERGED"})
eq(t, reqBody.Variables.Labels, []string{"one", "two"})
}