From 6a33adebbdf6a521161ac6a27c0587ddbd151f39 Mon Sep 17 00:00:00 2001 From: Pierce McEntagart Date: Thu, 16 Dec 2021 14:44:35 -0500 Subject: [PATCH 1/2] Change type of HookDelivery.InstallationID to Int64. --- github/github-accessors.go | 4 ++-- github/github-accessors_test.go | 2 +- github/github-stringify_test.go | 4 ++-- github/repos_hooks_deliveries.go | 2 +- github/repos_hooks_deliveries_test.go | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/github/github-accessors.go b/github/github-accessors.go index 189e68b33bf..3051b49bf09 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -5381,9 +5381,9 @@ func (h *HookDelivery) GetID() int64 { } // GetInstallationID returns the InstallationID field if it's non-nil, zero value otherwise. -func (h *HookDelivery) GetInstallationID() string { +func (h *HookDelivery) GetInstallationID() int64 { if h == nil || h.InstallationID == nil { - return "" + return 0 } return *h.InstallationID } diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 69ed4030668..b53b52032ee 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -6298,7 +6298,7 @@ func TestHookDelivery_GetID(tt *testing.T) { } func TestHookDelivery_GetInstallationID(tt *testing.T) { - var zeroValue string + var zeroValue int64 h := &HookDelivery{InstallationID: &zeroValue} h.GetInstallationID() h = &HookDelivery{} diff --git a/github/github-stringify_test.go b/github/github-stringify_test.go index 41228378e1c..425a51ce094 100644 --- a/github/github-stringify_test.go +++ b/github/github-stringify_test.go @@ -568,12 +568,12 @@ func TestHookDelivery_String(t *testing.T) { StatusCode: Int(0), Event: String(""), Action: String(""), - InstallationID: String(""), + InstallationID: Int64(0), RepositoryID: Int64(0), Request: &HookRequest{}, Response: &HookResponse{}, } - want := `github.HookDelivery{ID:0, GUID:"", DeliveredAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, Redelivery:false, Duration:0, Status:"", StatusCode:0, Event:"", Action:"", InstallationID:"", RepositoryID:0, Request:github.HookRequest{}, Response:github.HookResponse{}}` + want := `github.HookDelivery{ID:0, GUID:"", DeliveredAt:github.Timestamp{0001-01-01 00:00:00 +0000 UTC}, Redelivery:false, Duration:0, Status:"", StatusCode:0, Event:"", Action:"", InstallationID:0, RepositoryID:0, Request:github.HookRequest{}, Response:github.HookResponse{}}` if got := v.String(); got != want { t.Errorf("HookDelivery.String = %v, want %v", got, want) } diff --git a/github/repos_hooks_deliveries.go b/github/repos_hooks_deliveries.go index 122674463ae..d1d7520c908 100644 --- a/github/repos_hooks_deliveries.go +++ b/github/repos_hooks_deliveries.go @@ -26,7 +26,7 @@ type HookDelivery struct { StatusCode *int `json:"status_code"` Event *string `json:"event"` Action *string `json:"action"` - InstallationID *string `json:"installation_id"` + InstallationID *int64 `json:"installation_id"` RepositoryID *int64 `json:"repository_id"` // Request is populated by GetHookDelivery. diff --git a/github/repos_hooks_deliveries_test.go b/github/repos_hooks_deliveries_test.go index 8724e86320d..a7788831f05 100644 --- a/github/repos_hooks_deliveries_test.go +++ b/github/repos_hooks_deliveries_test.go @@ -288,7 +288,7 @@ func TestHookDelivery_Marshal(t *testing.T) { StatusCode: Int(1), Event: String("guid"), Action: String("guid"), - InstallationID: String("guid"), + InstallationID: Int64(1), RepositoryID: Int64(1), Request: &HookRequest{ Headers: header, @@ -310,7 +310,7 @@ func TestHookDelivery_Marshal(t *testing.T) { "status_code": 1, "event": "guid", "action": "guid", - "installation_id": "guid", + "installation_id": 1, "repository_id": 1, "request": { "headers": { From 8ba2c802eeb4daca7b738e58caac59e0b95a6b3d Mon Sep 17 00:00:00 2001 From: Pierce McEntagart Date: Tue, 21 Dec 2021 10:02:37 -0800 Subject: [PATCH 2/2] Add omitempty. --- github/repos_hooks_deliveries.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/github/repos_hooks_deliveries.go b/github/repos_hooks_deliveries.go index d1d7520c908..17132695191 100644 --- a/github/repos_hooks_deliveries.go +++ b/github/repos_hooks_deliveries.go @@ -17,17 +17,17 @@ import ( // - https://docs.github.com/en/rest/reference/repos#list-deliveries-for-a-repository-webhook // - https://docs.github.com/en/rest/reference/repos#get-a-delivery-for-a-repository-webhook type HookDelivery struct { - ID *int64 `json:"id"` - GUID *string `json:"guid"` - DeliveredAt *Timestamp `json:"delivered_at"` - Redelivery *bool `json:"redelivery"` - Duration *float64 `json:"duration"` - Status *string `json:"status"` - StatusCode *int `json:"status_code"` - Event *string `json:"event"` - Action *string `json:"action"` - InstallationID *int64 `json:"installation_id"` - RepositoryID *int64 `json:"repository_id"` + ID *int64 `json:"id,omitempty"` + GUID *string `json:"guid,omitempty"` + DeliveredAt *Timestamp `json:"delivered_at,omitempty"` + Redelivery *bool `json:"redelivery,omitempty"` + Duration *float64 `json:"duration,omitempty"` + Status *string `json:"status,omitempty"` + StatusCode *int `json:"status_code,omitempty"` + Event *string `json:"event,omitempty"` + Action *string `json:"action,omitempty"` + InstallationID *int64 `json:"installation_id,omitempty"` + RepositoryID *int64 `json:"repository_id,omitempty"` // Request is populated by GetHookDelivery. Request *HookRequest `json:"request,omitempty"`