From 4120f4361c5593c9199bdee5ed5247f40d7648d6 Mon Sep 17 00:00:00 2001 From: Sarah Funkhouser Date: Mon, 18 Oct 2021 21:29:50 -0400 Subject: [PATCH] audit log query options set should contain url tag --- github/orgs_audit_log.go | 6 +++--- github/orgs_audit_log_test.go | 9 ++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/github/orgs_audit_log.go b/github/orgs_audit_log.go index ca931a09d15..ade57f54113 100644 --- a/github/orgs_audit_log.go +++ b/github/orgs_audit_log.go @@ -12,9 +12,9 @@ import ( // GetAuditLogOptions sets up optional parameters to query audit-log endpoint. type GetAuditLogOptions struct { - Phrase *string `json:"phrase,omitempty"` // A search phrase. (Optional.) - Include *string `json:"include,omitempty"` // Event type includes. Can be one of "web", "git", "all". Default: "web". (Optional.) - Order *string `json:"order,omitempty"` // The order of audit log events. Can be one of "asc" or "desc". Default: "desc". (Optional.) + Phrase *string `url:"phrase,omitempty"` // A search phrase. (Optional.) + Include *string `url:"include,omitempty"` // Event type includes. Can be one of "web", "git", "all". Default: "web". (Optional.) + Order *string `url:"order,omitempty"` // The order of audit log events. Can be one of "asc" or "desc". Default: "desc". (Optional.) ListCursorOptions } diff --git a/github/orgs_audit_log_test.go b/github/orgs_audit_log_test.go index 1537877f4d3..c2beca2bdd6 100644 --- a/github/orgs_audit_log_test.go +++ b/github/orgs_audit_log_test.go @@ -9,6 +9,7 @@ import ( "context" "fmt" "net/http" + "strings" "testing" "time" @@ -57,7 +58,7 @@ func TestOrganizationService_GetAuditLog(t *testing.T) { Order: String("asc"), } - auditEntries, _, err := client.Organizations.GetAuditLog(ctx, "o", &getOpts) + auditEntries, resp, err := client.Organizations.GetAuditLog(ctx, "o", &getOpts) if err != nil { t.Errorf("Organizations.GetAuditLog returned error: %v", err) } @@ -97,6 +98,12 @@ func TestOrganizationService_GetAuditLog(t *testing.T) { t.Errorf("Organizations.GetAuditLog return \ngot: %+v,\nwant:%+v", auditEntries, want) } + // assert query string has lower case params + requestedQuery := resp.Request.URL.RawQuery + if !strings.Contains(requestedQuery, "phrase") { + t.Errorf("Organizations.GetAuditLog query string \ngot: %+v,\nwant:%+v", requestedQuery, "phrase") + } + const methodName = "GetAuditLog" testBadOptions(t, methodName, func() (err error) { _, _, err = client.Organizations.GetAuditLog(ctx, "\n", &getOpts)