Properly handle issue and pr state options when building search queries (#5513)
This commit is contained in:
parent
19a852ae9f
commit
db85b1d3cb
3 changed files with 12 additions and 4 deletions
|
|
@ -217,7 +217,7 @@ func TestIssueList_web(t *testing.T) {
|
|||
|
||||
assert.Equal(t, "", stdout.String())
|
||||
assert.Equal(t, "Opening github.com/OWNER/REPO/issues in your browser.\n", stderr.String())
|
||||
browser.Verify(t, "https://github.com/OWNER/REPO/issues?q=assignee%3Apeter+author%3Ajohn+label%3Abug+label%3Adocs+mentions%3Afrank+milestone%3Av1.1+state%3Aall+type%3Aissue")
|
||||
browser.Verify(t, "https://github.com/OWNER/REPO/issues?q=assignee%3Apeter+author%3Ajohn+label%3Abug+label%3Adocs+mentions%3Afrank+milestone%3Av1.1+type%3Aissue")
|
||||
}
|
||||
|
||||
func Test_issueList(t *testing.T) {
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ func TestPRList_filteringAssignee(t *testing.T) {
|
|||
http.Register(
|
||||
httpmock.GraphQL(`query PullRequestSearch\b`),
|
||||
httpmock.GraphQLQuery(`{}`, func(_ string, params map[string]interface{}) {
|
||||
assert.Equal(t, `assignee:hubot base:develop label:"needs tests" repo:OWNER/REPO state:merged type:pr`, params["q"].(string))
|
||||
assert.Equal(t, `assignee:hubot base:develop is:merged label:"needs tests" repo:OWNER/REPO type:pr`, params["q"].(string))
|
||||
}))
|
||||
|
||||
_, err := runCommand(http, true, `-s merged -l "needs tests" -a hubot -B develop`)
|
||||
|
|
@ -277,7 +277,7 @@ func TestPRList_web(t *testing.T) {
|
|||
{
|
||||
name: "filters",
|
||||
cli: "-a peter -l bug -l docs -L 10 -s merged -B trunk",
|
||||
expectedBrowserURL: "https://github.com/OWNER/REPO/pulls?q=assignee%3Apeter+base%3Atrunk+label%3Abug+label%3Adocs+state%3Amerged+type%3Apr",
|
||||
expectedBrowserURL: "https://github.com/OWNER/REPO/pulls?q=assignee%3Apeter+base%3Atrunk+is%3Amerged+label%3Abug+label%3Adocs+type%3Apr",
|
||||
},
|
||||
{
|
||||
name: "draft",
|
||||
|
|
|
|||
|
|
@ -208,6 +208,13 @@ func ListURLWithQuery(listURL string, options FilterOptions) (string, error) {
|
|||
}
|
||||
|
||||
func SearchQueryBuild(options FilterOptions) string {
|
||||
var is, state string
|
||||
switch options.State {
|
||||
case "open", "closed":
|
||||
state = options.State
|
||||
case "merged":
|
||||
is = "merged"
|
||||
}
|
||||
q := search.Query{
|
||||
Qualifiers: search.Qualifiers{
|
||||
Assignee: options.Assignee,
|
||||
|
|
@ -219,7 +226,8 @@ func SearchQueryBuild(options FilterOptions) string {
|
|||
Mentions: options.Mention,
|
||||
Milestone: options.Milestone,
|
||||
Repo: []string{options.Repo},
|
||||
State: options.State,
|
||||
State: state,
|
||||
Is: []string{is},
|
||||
Type: options.Entity,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue