@@ -13,6 +13,7 @@ import (
1313
1414 "github.com/github/gh-cli/test"
1515 "github.com/github/gh-cli/utils"
16+ "github.com/spf13/pflag"
1617)
1718
1819func eq (t * testing.T , got interface {}, expected interface {}) {
@@ -100,6 +101,39 @@ func TestPRList_filtering(t *testing.T) {
100101 eq (t , reqBody .Variables .Labels , []string {"one" , "two" })
101102}
102103
104+ func TestPRList_filteringAssignee (t * testing.T ) {
105+ initBlankContext ("OWNER/REPO" , "master" )
106+ http := initFakeHTTP ()
107+
108+ respBody := bytes .NewBufferString (`{ "data": {} }` )
109+ http .StubResponse (200 , respBody )
110+
111+ prListCmd .SetOut (ioutil .Discard )
112+ // Reset flag slice values so they don't leak between tests
113+ // TODO: generalize this hack
114+ prListCmd .Flags ().Visit (func (f * pflag.Flag ) {
115+ if v , ok := f .Value .(pflag.SliceValue ); ok {
116+ v .Replace ([]string {})
117+ }
118+ })
119+
120+ RootCmd .SetArgs ([]string {"pr" , "list" , "-s" , "merged" , "-l" , "one two" , "-a" , "hubot" , "-B" , "develop" })
121+ _ , err := RootCmd .ExecuteC ()
122+ if err != nil {
123+ t .Fatal (err )
124+ }
125+
126+ bodyBytes , _ := ioutil .ReadAll (http .Requests [0 ].Body )
127+ reqBody := struct {
128+ Variables struct {
129+ Q string
130+ }
131+ }{}
132+ json .Unmarshal (bodyBytes , & reqBody )
133+
134+ eq (t , reqBody .Variables .Q , `repo:OWNER/REPO assignee:hubot is:pr sort:created-desc is:merged label:"one two" base:"develop"` )
135+ }
136+
103137func TestPRView_currentBranch (t * testing.T ) {
104138 initBlankContext ("OWNER/REPO" , "blueberries" )
105139 http := initFakeHTTP ()
0 commit comments