Skip to content

Commit c4b2cb9

Browse files
authored
fix: Add missing query params to AlertListOptions (#3477)
1 parent 77684a4 commit c4b2cb9

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

Diff for: github/code_scanning.go

+9
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,15 @@ type AlertListOptions struct {
141141
// The name of a code scanning tool. Only results by this tool will be listed.
142142
ToolName string `url:"tool_name,omitempty"`
143143

144+
// The GUID of a code scanning tool. Only results by this tool will be listed.
145+
ToolGUID string `url:"tool_guid,omitempty"`
146+
147+
// The direction to sort the results by. Possible values are: asc, desc. Default: desc.
148+
Direction string `url:"direction,omitempty"`
149+
150+
// The property by which to sort the results. Possible values are: created, updated. Default: created.
151+
Sort string `url:"sort,omitempty"`
152+
144153
ListCursorOptions
145154

146155
// Add ListOptions so offset pagination with integer type "page" query parameter is accepted

Diff for: github/code_scanning_test.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ func TestCodeScanningService_ListAlertsForOrg(t *testing.T) {
147147

148148
mux.HandleFunc("/orgs/o/code-scanning/alerts", func(w http.ResponseWriter, r *http.Request) {
149149
testMethod(t, r, "GET")
150-
testFormValues(t, r, values{"state": "open", "ref": "heads/master", "severity": "warning", "tool_name": "CodeQL"})
150+
testFormValues(t, r, values{"state": "open", "ref": "heads/master", "severity": "warning", "tool_name": "CodeQL", "tool_guid": "guid", "direction": "asc", "sort": "updated"})
151151
fmt.Fprint(w, `[{
152152
"repository": {
153153
"id": 1,
@@ -159,7 +159,7 @@ func TestCodeScanningService_ListAlertsForOrg(t *testing.T) {
159159
"rule_description":"Useless conditional",
160160
"tool": {
161161
"name": "CodeQL",
162-
"guid": null,
162+
"guid": "guid",
163163
"version": "1.4.0"
164164
},
165165
"rule": {
@@ -239,7 +239,7 @@ func TestCodeScanningService_ListAlertsForOrg(t *testing.T) {
239239
}]`)
240240
})
241241

242-
opts := &AlertListOptions{State: "open", Ref: "heads/master", Severity: "warning", ToolName: "CodeQL"}
242+
opts := &AlertListOptions{State: "open", Ref: "heads/master", Severity: "warning", ToolName: "CodeQL", ToolGUID: "guid", Direction: "asc", Sort: "updated"}
243243
ctx := context.Background()
244244
alerts, _, err := client.CodeScanning.ListAlertsForOrg(ctx, "o", opts)
245245
if err != nil {
@@ -257,7 +257,7 @@ func TestCodeScanningService_ListAlertsForOrg(t *testing.T) {
257257
RuleID: Ptr("js/trivial-conditional"),
258258
RuleSeverity: Ptr("warning"),
259259
RuleDescription: Ptr("Useless conditional"),
260-
Tool: &Tool{Name: Ptr("CodeQL"), GUID: nil, Version: Ptr("1.4.0")},
260+
Tool: &Tool{Name: Ptr("CodeQL"), GUID: Ptr("guid"), Version: Ptr("1.4.0")},
261261
Rule: &Rule{
262262
ID: Ptr("js/trivial-conditional"),
263263
Severity: Ptr("warning"),
@@ -477,14 +477,14 @@ func TestCodeScanningService_ListAlertsForRepo(t *testing.T) {
477477

478478
mux.HandleFunc("/repos/o/r/code-scanning/alerts", func(w http.ResponseWriter, r *http.Request) {
479479
testMethod(t, r, "GET")
480-
testFormValues(t, r, values{"state": "open", "ref": "heads/master", "severity": "warning", "tool_name": "CodeQL"})
480+
testFormValues(t, r, values{"state": "open", "ref": "heads/master", "severity": "warning", "tool_name": "CodeQL", "tool_guid": "guid", "direction": "asc", "sort": "updated"})
481481
fmt.Fprint(w, `[{
482482
"rule_id":"js/trivial-conditional",
483483
"rule_severity":"warning",
484484
"rule_description":"Useless conditional",
485485
"tool": {
486486
"name": "CodeQL",
487-
"guid": null,
487+
"guid": "guid",
488488
"version": "1.4.0"
489489
},
490490
"rule": {
@@ -526,7 +526,7 @@ func TestCodeScanningService_ListAlertsForRepo(t *testing.T) {
526526
"rule_description":"Expression has no effect",
527527
"tool": {
528528
"name": "CodeQL",
529-
"guid": null,
529+
"guid": "guid",
530530
"version": "1.4.0"
531531
},
532532
"rule": {
@@ -564,7 +564,7 @@ func TestCodeScanningService_ListAlertsForRepo(t *testing.T) {
564564
}]`)
565565
})
566566

567-
opts := &AlertListOptions{State: "open", Ref: "heads/master", Severity: "warning", ToolName: "CodeQL"}
567+
opts := &AlertListOptions{State: "open", Ref: "heads/master", Severity: "warning", ToolName: "CodeQL", ToolGUID: "guid", Direction: "asc", Sort: "updated"}
568568
ctx := context.Background()
569569
alerts, _, err := client.CodeScanning.ListAlertsForRepo(ctx, "o", "r", opts)
570570
if err != nil {
@@ -577,7 +577,7 @@ func TestCodeScanningService_ListAlertsForRepo(t *testing.T) {
577577
RuleID: Ptr("js/trivial-conditional"),
578578
RuleSeverity: Ptr("warning"),
579579
RuleDescription: Ptr("Useless conditional"),
580-
Tool: &Tool{Name: Ptr("CodeQL"), GUID: nil, Version: Ptr("1.4.0")},
580+
Tool: &Tool{Name: Ptr("CodeQL"), GUID: Ptr("guid"), Version: Ptr("1.4.0")},
581581
Rule: &Rule{
582582
ID: Ptr("js/trivial-conditional"),
583583
Severity: Ptr("warning"),
@@ -613,7 +613,7 @@ func TestCodeScanningService_ListAlertsForRepo(t *testing.T) {
613613
RuleID: Ptr("js/useless-expression"),
614614
RuleSeverity: Ptr("warning"),
615615
RuleDescription: Ptr("Expression has no effect"),
616-
Tool: &Tool{Name: Ptr("CodeQL"), GUID: nil, Version: Ptr("1.4.0")},
616+
Tool: &Tool{Name: Ptr("CodeQL"), GUID: Ptr("guid"), Version: Ptr("1.4.0")},
617617
Rule: &Rule{
618618
ID: Ptr("js/useless-expression"),
619619
Severity: Ptr("warning"),

0 commit comments

Comments
 (0)