From c91e874783420ee2e386226917603bb15775b412 Mon Sep 17 00:00:00 2001 From: Gregor Jasny Date: Wed, 5 Nov 2025 14:17:25 +0100 Subject: [PATCH 1/3] feat: Address post-merge enterprise billing cost center review --- github/enterprise_billing_cost_centers.go | 9 ++--- .../enterprise_billing_cost_centers_test.go | 8 ++--- github/github-accessors.go | 24 +++++--------- github/github-accessors_test.go | 33 +++++++------------ 4 files changed, 28 insertions(+), 46 deletions(-) diff --git a/github/enterprise_billing_cost_centers.go b/github/enterprise_billing_cost_centers.go index 681bf9ec000..10fa9c32a36 100644 --- a/github/enterprise_billing_cost_centers.go +++ b/github/enterprise_billing_cost_centers.go @@ -30,14 +30,15 @@ type CostCenters struct { CostCenters []*CostCenter `json:"costCenters,omitempty"` } -// CostCenterListOptions specifies optional parameters to the EnterpriseService.ListCostCenters method. -type CostCenterListOptions struct { +// ListCostCenterOptions specifies optional parameters to the EnterpriseService.ListCostCenters method. +type ListCostCenterOptions struct { + // Set to `active` or `deleted` to only list cost centers in a specific state. State *string `url:"state,omitempty"` } // CostCenterRequest represents a request to create or update a cost center. type CostCenterRequest struct { - Name *string `json:"name,omitempty"` + Name string `json:"name"` } // CostCenterResourceRequest represents a request to add or remove resources from a cost center. @@ -78,7 +79,7 @@ type CostCenterDeleteResponse struct { // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/billing#get-all-cost-centers-for-an-enterprise // //meta:operation GET /enterprises/{enterprise}/settings/billing/cost-centers -func (s *EnterpriseService) ListCostCenters(ctx context.Context, enterprise string, opts *CostCenterListOptions) (*CostCenters, *Response, error) { +func (s *EnterpriseService) ListCostCenters(ctx context.Context, enterprise string, opts *ListCostCenterOptions) (*CostCenters, *Response, error) { u := fmt.Sprintf("enterprises/%v/settings/billing/cost-centers", enterprise) u, err := addOptions(u, opts) if err != nil { diff --git a/github/enterprise_billing_cost_centers_test.go b/github/enterprise_billing_cost_centers_test.go index d450a701eb5..7c9ccc757f9 100644 --- a/github/enterprise_billing_cost_centers_test.go +++ b/github/enterprise_billing_cost_centers_test.go @@ -56,7 +56,7 @@ func TestEnterpriseService_ListCostCenters(t *testing.T) { }) ctx := t.Context() - opts := &CostCenterListOptions{ + opts := &ListCostCenterOptions{ State: Ptr("active"), } costCenters, _, err := client.Enterprise.ListCostCenters(ctx, "e", opts) @@ -139,7 +139,7 @@ func TestEnterpriseService_CreateCostCenter(t *testing.T) { ctx := t.Context() req := CostCenterRequest{ - Name: Ptr("Engineering Team"), + Name: "Engineering Team", } costCenter, _, err := client.Enterprise.CreateCostCenter(ctx, "e", req) if err != nil { @@ -280,7 +280,7 @@ func TestEnterpriseService_UpdateCostCenter(t *testing.T) { ctx := t.Context() req := CostCenterRequest{ - Name: Ptr("Updated Cost Center Name"), + Name: "Updated Cost Center Name", } costCenter, _, err := client.Enterprise.UpdateCostCenter(ctx, "e", "2eeb8ffe-6903-11ee-8c99-0242ac120002", req) if err != nil { @@ -607,7 +607,7 @@ func TestCostCenterRequest_Marshal(t *testing.T) { testJSONMarshal(t, &CostCenterRequest{}, "{}") u := &CostCenterRequest{ - Name: Ptr("Engineering"), + Name: "Engineering", } want := `{ diff --git a/github/github-accessors.go b/github/github-accessors.go index c32e2159611..a52f57eca8d 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -6118,14 +6118,6 @@ func (c *CostCenterDeleteResponse) GetName() string { return *c.Name } -// GetState returns the State field if it's non-nil, zero value otherwise. -func (c *CostCenterListOptions) GetState() string { - if c == nil || c.State == nil { - return "" - } - return *c.State -} - // GetMessage returns the Message field if it's non-nil, zero value otherwise. func (c *CostCenterRemoveResourceResponse) GetMessage() string { if c == nil || c.Message == nil { @@ -6134,14 +6126,6 @@ func (c *CostCenterRemoveResourceResponse) GetMessage() string { return *c.Message } -// GetName returns the Name field if it's non-nil, zero value otherwise. -func (c *CostCenterRequest) GetName() string { - if c == nil || c.Name == nil { - return "" - } - return *c.Name -} - // GetCompletedAt returns the CompletedAt field if it's non-nil, zero value otherwise. func (c *CreateCheckRunOptions) GetCompletedAt() Timestamp { if c == nil || c.CompletedAt == nil { @@ -14046,6 +14030,14 @@ func (l *ListCodespaces) GetTotalCount() int { return *l.TotalCount } +// GetState returns the State field if it's non-nil, zero value otherwise. +func (l *ListCostCenterOptions) GetState() string { + if l == nil || l.State == nil { + return "" + } + return *l.State +} + // GetTotalCount returns the TotalCount field if it's non-nil, zero value otherwise. func (l *ListCustomDeploymentRuleIntegrationsResponse) GetTotalCount() int { if l == nil || l.TotalCount == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index d3bef6e4a9d..05836264987 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -7985,17 +7985,6 @@ func TestCostCenterDeleteResponse_GetName(tt *testing.T) { c.GetName() } -func TestCostCenterListOptions_GetState(tt *testing.T) { - tt.Parallel() - var zeroValue string - c := &CostCenterListOptions{State: &zeroValue} - c.GetState() - c = &CostCenterListOptions{} - c.GetState() - c = nil - c.GetState() -} - func TestCostCenterRemoveResourceResponse_GetMessage(tt *testing.T) { tt.Parallel() var zeroValue string @@ -8007,17 +7996,6 @@ func TestCostCenterRemoveResourceResponse_GetMessage(tt *testing.T) { c.GetMessage() } -func TestCostCenterRequest_GetName(tt *testing.T) { - tt.Parallel() - var zeroValue string - c := &CostCenterRequest{Name: &zeroValue} - c.GetName() - c = &CostCenterRequest{} - c.GetName() - c = nil - c.GetName() -} - func TestCreateCheckRunOptions_GetCompletedAt(tt *testing.T) { tt.Parallel() var zeroValue Timestamp @@ -18244,6 +18222,17 @@ func TestListCodespaces_GetTotalCount(tt *testing.T) { l.GetTotalCount() } +func TestListCostCenterOptions_GetState(tt *testing.T) { + tt.Parallel() + var zeroValue string + l := &ListCostCenterOptions{State: &zeroValue} + l.GetState() + l = &ListCostCenterOptions{} + l.GetState() + l = nil + l.GetState() +} + func TestListCustomDeploymentRuleIntegrationsResponse_GetTotalCount(tt *testing.T) { tt.Parallel() var zeroValue int From 996d0a49e94822138a143d586542a5ae38b3a52c Mon Sep 17 00:00:00 2001 From: Gregor Jasny Date: Wed, 5 Nov 2025 17:03:59 +0100 Subject: [PATCH 2/3] fixup! feat: Address post-merge enterprise billing cost center review --- github/enterprise_billing_cost_centers.go | 24 ++-- .../enterprise_billing_cost_centers_test.go | 6 +- github/github-accessors.go | 96 ++++++------- github/github-accessors_test.go | 132 +++++++++--------- 4 files changed, 129 insertions(+), 129 deletions(-) diff --git a/github/enterprise_billing_cost_centers.go b/github/enterprise_billing_cost_centers.go index 10fa9c32a36..081012401c8 100644 --- a/github/enterprise_billing_cost_centers.go +++ b/github/enterprise_billing_cost_centers.go @@ -48,8 +48,8 @@ type CostCenterResourceRequest struct { Repositories []string `json:"repositories,omitempty"` } -// CostCenterAddResourceResponse represents a response from adding resources to a cost center. -type CostCenterAddResourceResponse struct { +// AddResourcesToCostCenterResponse represents a response from adding resources to a cost center. +type AddResourcesToCostCenterResponse struct { Message *string `json:"message,omitempty"` ReassignedResources []*ReassignedResource `json:"reassigned_resources,omitempty"` } @@ -61,13 +61,13 @@ type ReassignedResource struct { PreviousCostCenter *string `json:"previous_cost_center,omitempty"` } -// CostCenterRemoveResourceResponse represents a response from removing resources from a cost center. -type CostCenterRemoveResourceResponse struct { +// RemoveResourcesFromCostCenterResponse represents a response from removing resources from a cost center. +type RemoveResourcesFromCostCenterResponse struct { Message *string `json:"message,omitempty"` } -// CostCenterDeleteResponse represents a response from deleting a cost center. -type CostCenterDeleteResponse struct { +// DeleteCostCenterResponse represents a response from deleting a cost center. +type DeleteCostCenterResponse struct { Message *string `json:"message,omitempty"` ID *string `json:"id,omitempty"` Name *string `json:"name,omitempty"` @@ -171,7 +171,7 @@ func (s *EnterpriseService) UpdateCostCenter(ctx context.Context, enterprise, co // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/billing#delete-a-cost-center // //meta:operation DELETE /enterprises/{enterprise}/settings/billing/cost-centers/{cost_center_id} -func (s *EnterpriseService) DeleteCostCenter(ctx context.Context, enterprise, costCenterID string) (*CostCenterDeleteResponse, *Response, error) { +func (s *EnterpriseService) DeleteCostCenter(ctx context.Context, enterprise, costCenterID string) (*DeleteCostCenterResponse, *Response, error) { u := fmt.Sprintf("enterprises/%v/settings/billing/cost-centers/%v", enterprise, costCenterID) req, err := s.client.NewRequest("DELETE", u, nil) @@ -179,7 +179,7 @@ func (s *EnterpriseService) DeleteCostCenter(ctx context.Context, enterprise, co return nil, nil, err } - result := &CostCenterDeleteResponse{} + result := &DeleteCostCenterResponse{} resp, err := s.client.Do(ctx, req, result) if err != nil { return nil, resp, err @@ -193,7 +193,7 @@ func (s *EnterpriseService) DeleteCostCenter(ctx context.Context, enterprise, co // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/billing#add-resources-to-a-cost-center // //meta:operation POST /enterprises/{enterprise}/settings/billing/cost-centers/{cost_center_id}/resource -func (s *EnterpriseService) AddResourcesToCostCenter(ctx context.Context, enterprise, costCenterID string, resources CostCenterResourceRequest) (*CostCenterAddResourceResponse, *Response, error) { +func (s *EnterpriseService) AddResourcesToCostCenter(ctx context.Context, enterprise, costCenterID string, resources CostCenterResourceRequest) (*AddResourcesToCostCenterResponse, *Response, error) { u := fmt.Sprintf("enterprises/%v/settings/billing/cost-centers/%v/resource", enterprise, costCenterID) req, err := s.client.NewRequest("POST", u, resources) @@ -201,7 +201,7 @@ func (s *EnterpriseService) AddResourcesToCostCenter(ctx context.Context, enterp return nil, nil, err } - result := &CostCenterAddResourceResponse{} + result := &AddResourcesToCostCenterResponse{} resp, err := s.client.Do(ctx, req, result) if err != nil { return nil, resp, err @@ -215,7 +215,7 @@ func (s *EnterpriseService) AddResourcesToCostCenter(ctx context.Context, enterp // GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/enterprise-admin/billing#remove-resources-from-a-cost-center // //meta:operation DELETE /enterprises/{enterprise}/settings/billing/cost-centers/{cost_center_id}/resource -func (s *EnterpriseService) RemoveResourcesFromCostCenter(ctx context.Context, enterprise, costCenterID string, resources CostCenterResourceRequest) (*CostCenterRemoveResourceResponse, *Response, error) { +func (s *EnterpriseService) RemoveResourcesFromCostCenter(ctx context.Context, enterprise, costCenterID string, resources CostCenterResourceRequest) (*RemoveResourcesFromCostCenterResponse, *Response, error) { u := fmt.Sprintf("enterprises/%v/settings/billing/cost-centers/%v/resource", enterprise, costCenterID) req, err := s.client.NewRequest("DELETE", u, resources) @@ -223,7 +223,7 @@ func (s *EnterpriseService) RemoveResourcesFromCostCenter(ctx context.Context, e return nil, nil, err } - result := &CostCenterRemoveResourceResponse{} + result := &RemoveResourcesFromCostCenterResponse{} resp, err := s.client.Do(ctx, req, result) if err != nil { return nil, resp, err diff --git a/github/enterprise_billing_cost_centers_test.go b/github/enterprise_billing_cost_centers_test.go index 7c9ccc757f9..2a7208afd6d 100644 --- a/github/enterprise_billing_cost_centers_test.go +++ b/github/enterprise_billing_cost_centers_test.go @@ -351,7 +351,7 @@ func TestEnterpriseService_DeleteCostCenter(t *testing.T) { t.Errorf("Enterprise.DeleteCostCenter returned error: %v", err) } - want := &CostCenterDeleteResponse{ + want := &DeleteCostCenterResponse{ Message: Ptr("Cost center successfully deleted."), ID: Ptr("2eeb8ffe-6903-11ee-8c99-0242ac120002"), Name: Ptr("Engineering Team"), @@ -423,7 +423,7 @@ func TestEnterpriseService_AddResourcesToCostCenter(t *testing.T) { t.Errorf("Enterprise.AddResourcesToCostCenter returned error: %v", err) } - want := &CostCenterAddResourceResponse{ + want := &AddResourcesToCostCenterResponse{ Message: Ptr("Resources successfully added to the cost center."), ReassignedResources: []*ReassignedResource{ { @@ -492,7 +492,7 @@ func TestEnterpriseService_RemoveResourcesFromCostCenter(t *testing.T) { t.Errorf("Enterprise.RemoveResourcesFromCostCenter returned error: %v", err) } - want := &CostCenterRemoveResourceResponse{ + want := &RemoveResourcesFromCostCenterResponse{ Message: Ptr("Resources successfully removed from the cost center."), } if !cmp.Equal(result, want) { diff --git a/github/github-accessors.go b/github/github-accessors.go index a52f57eca8d..3569b8e5df2 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -342,6 +342,14 @@ func (a *ActorLocation) GetCountryCode() string { return *a.CountryCode } +// GetMessage returns the Message field if it's non-nil, zero value otherwise. +func (a *AddResourcesToCostCenterResponse) GetMessage() string { + if a == nil || a.Message == nil { + return "" + } + return *a.Message +} + // GetFrom returns the From field if it's non-nil, zero value otherwise. func (a *AdminEnforcedChanges) GetFrom() bool { if a == nil || a.From == nil { @@ -6078,54 +6086,6 @@ func (c *CostCenter) GetState() string { return *c.State } -// GetMessage returns the Message field if it's non-nil, zero value otherwise. -func (c *CostCenterAddResourceResponse) GetMessage() string { - if c == nil || c.Message == nil { - return "" - } - return *c.Message -} - -// GetCostCenterState returns the CostCenterState field if it's non-nil, zero value otherwise. -func (c *CostCenterDeleteResponse) GetCostCenterState() string { - if c == nil || c.CostCenterState == nil { - return "" - } - return *c.CostCenterState -} - -// GetID returns the ID field if it's non-nil, zero value otherwise. -func (c *CostCenterDeleteResponse) GetID() string { - if c == nil || c.ID == nil { - return "" - } - return *c.ID -} - -// GetMessage returns the Message field if it's non-nil, zero value otherwise. -func (c *CostCenterDeleteResponse) GetMessage() string { - if c == nil || c.Message == nil { - return "" - } - return *c.Message -} - -// GetName returns the Name field if it's non-nil, zero value otherwise. -func (c *CostCenterDeleteResponse) GetName() string { - if c == nil || c.Name == nil { - return "" - } - return *c.Name -} - -// GetMessage returns the Message field if it's non-nil, zero value otherwise. -func (c *CostCenterRemoveResourceResponse) GetMessage() string { - if c == nil || c.Message == nil { - return "" - } - return *c.Message -} - // GetCompletedAt returns the CompletedAt field if it's non-nil, zero value otherwise. func (c *CreateCheckRunOptions) GetCompletedAt() Timestamp { if c == nil || c.CompletedAt == nil { @@ -7134,6 +7094,38 @@ func (d *DeleteAnalysis) GetNextAnalysisURL() string { return *d.NextAnalysisURL } +// GetCostCenterState returns the CostCenterState field if it's non-nil, zero value otherwise. +func (d *DeleteCostCenterResponse) GetCostCenterState() string { + if d == nil || d.CostCenterState == nil { + return "" + } + return *d.CostCenterState +} + +// GetID returns the ID field if it's non-nil, zero value otherwise. +func (d *DeleteCostCenterResponse) GetID() string { + if d == nil || d.ID == nil { + return "" + } + return *d.ID +} + +// GetMessage returns the Message field if it's non-nil, zero value otherwise. +func (d *DeleteCostCenterResponse) GetMessage() string { + if d == nil || d.Message == nil { + return "" + } + return *d.Message +} + +// GetName returns the Name field if it's non-nil, zero value otherwise. +func (d *DeleteCostCenterResponse) GetName() string { + if d == nil || d.Name == nil { + return "" + } + return *d.Name +} + // GetInstallation returns the Installation field. func (d *DeleteEvent) GetInstallation() *Installation { if d == nil { @@ -22382,6 +22374,14 @@ func (r *ReleaseVersion) GetVersion() string { return *r.Version } +// GetMessage returns the Message field if it's non-nil, zero value otherwise. +func (r *RemoveResourcesFromCostCenterResponse) GetMessage() string { + if r == nil || r.Message == nil { + return "" + } + return *r.Message +} + // GetExpiresAt returns the ExpiresAt field if it's non-nil, zero value otherwise. func (r *RemoveToken) GetExpiresAt() Timestamp { if r == nil || r.ExpiresAt == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index 05836264987..da3fdfc2944 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -457,6 +457,17 @@ func TestActorLocation_GetCountryCode(tt *testing.T) { a.GetCountryCode() } +func TestAddResourcesToCostCenterResponse_GetMessage(tt *testing.T) { + tt.Parallel() + var zeroValue string + a := &AddResourcesToCostCenterResponse{Message: &zeroValue} + a.GetMessage() + a = &AddResourcesToCostCenterResponse{} + a.GetMessage() + a = nil + a.GetMessage() +} + func TestAdminEnforcedChanges_GetFrom(tt *testing.T) { tt.Parallel() var zeroValue bool @@ -7930,72 +7941,6 @@ func TestCostCenter_GetState(tt *testing.T) { c.GetState() } -func TestCostCenterAddResourceResponse_GetMessage(tt *testing.T) { - tt.Parallel() - var zeroValue string - c := &CostCenterAddResourceResponse{Message: &zeroValue} - c.GetMessage() - c = &CostCenterAddResourceResponse{} - c.GetMessage() - c = nil - c.GetMessage() -} - -func TestCostCenterDeleteResponse_GetCostCenterState(tt *testing.T) { - tt.Parallel() - var zeroValue string - c := &CostCenterDeleteResponse{CostCenterState: &zeroValue} - c.GetCostCenterState() - c = &CostCenterDeleteResponse{} - c.GetCostCenterState() - c = nil - c.GetCostCenterState() -} - -func TestCostCenterDeleteResponse_GetID(tt *testing.T) { - tt.Parallel() - var zeroValue string - c := &CostCenterDeleteResponse{ID: &zeroValue} - c.GetID() - c = &CostCenterDeleteResponse{} - c.GetID() - c = nil - c.GetID() -} - -func TestCostCenterDeleteResponse_GetMessage(tt *testing.T) { - tt.Parallel() - var zeroValue string - c := &CostCenterDeleteResponse{Message: &zeroValue} - c.GetMessage() - c = &CostCenterDeleteResponse{} - c.GetMessage() - c = nil - c.GetMessage() -} - -func TestCostCenterDeleteResponse_GetName(tt *testing.T) { - tt.Parallel() - var zeroValue string - c := &CostCenterDeleteResponse{Name: &zeroValue} - c.GetName() - c = &CostCenterDeleteResponse{} - c.GetName() - c = nil - c.GetName() -} - -func TestCostCenterRemoveResourceResponse_GetMessage(tt *testing.T) { - tt.Parallel() - var zeroValue string - c := &CostCenterRemoveResourceResponse{Message: &zeroValue} - c.GetMessage() - c = &CostCenterRemoveResourceResponse{} - c.GetMessage() - c = nil - c.GetMessage() -} - func TestCreateCheckRunOptions_GetCompletedAt(tt *testing.T) { tt.Parallel() var zeroValue Timestamp @@ -9319,6 +9264,50 @@ func TestDeleteAnalysis_GetNextAnalysisURL(tt *testing.T) { d.GetNextAnalysisURL() } +func TestDeleteCostCenterResponse_GetCostCenterState(tt *testing.T) { + tt.Parallel() + var zeroValue string + d := &DeleteCostCenterResponse{CostCenterState: &zeroValue} + d.GetCostCenterState() + d = &DeleteCostCenterResponse{} + d.GetCostCenterState() + d = nil + d.GetCostCenterState() +} + +func TestDeleteCostCenterResponse_GetID(tt *testing.T) { + tt.Parallel() + var zeroValue string + d := &DeleteCostCenterResponse{ID: &zeroValue} + d.GetID() + d = &DeleteCostCenterResponse{} + d.GetID() + d = nil + d.GetID() +} + +func TestDeleteCostCenterResponse_GetMessage(tt *testing.T) { + tt.Parallel() + var zeroValue string + d := &DeleteCostCenterResponse{Message: &zeroValue} + d.GetMessage() + d = &DeleteCostCenterResponse{} + d.GetMessage() + d = nil + d.GetMessage() +} + +func TestDeleteCostCenterResponse_GetName(tt *testing.T) { + tt.Parallel() + var zeroValue string + d := &DeleteCostCenterResponse{Name: &zeroValue} + d.GetName() + d = &DeleteCostCenterResponse{} + d.GetName() + d = nil + d.GetName() +} + func TestDeleteEvent_GetInstallation(tt *testing.T) { tt.Parallel() d := &DeleteEvent{} @@ -28902,6 +28891,17 @@ func TestReleaseVersion_GetVersion(tt *testing.T) { r.GetVersion() } +func TestRemoveResourcesFromCostCenterResponse_GetMessage(tt *testing.T) { + tt.Parallel() + var zeroValue string + r := &RemoveResourcesFromCostCenterResponse{Message: &zeroValue} + r.GetMessage() + r = &RemoveResourcesFromCostCenterResponse{} + r.GetMessage() + r = nil + r.GetMessage() +} + func TestRemoveToken_GetExpiresAt(tt *testing.T) { tt.Parallel() var zeroValue Timestamp From 68990a7b0b71e9048db82b9762c07fe0ca3e0077 Mon Sep 17 00:00:00 2001 From: Gregor Jasny Date: Thu, 6 Nov 2025 14:06:02 +0100 Subject: [PATCH 3/3] fixup! feat: Address post-merge enterprise billing cost center review --- github/enterprise_billing_cost_centers.go | 8 ++-- .../enterprise_billing_cost_centers_test.go | 29 ++++++++++-- github/github-accessors.go | 32 -------------- github/github-accessors_test.go | 44 ------------------- 4 files changed, 29 insertions(+), 84 deletions(-) diff --git a/github/enterprise_billing_cost_centers.go b/github/enterprise_billing_cost_centers.go index 081012401c8..97fba64052a 100644 --- a/github/enterprise_billing_cost_centers.go +++ b/github/enterprise_billing_cost_centers.go @@ -68,10 +68,10 @@ type RemoveResourcesFromCostCenterResponse struct { // DeleteCostCenterResponse represents a response from deleting a cost center. type DeleteCostCenterResponse struct { - Message *string `json:"message,omitempty"` - ID *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - CostCenterState *string `json:"costCenterState,omitempty"` + Message string `json:"message"` + ID string `json:"id"` + Name string `json:"name"` + CostCenterState string `json:"costCenterState"` } // ListCostCenters lists all cost centers for an enterprise. diff --git a/github/enterprise_billing_cost_centers_test.go b/github/enterprise_billing_cost_centers_test.go index 2a7208afd6d..ce047b862e7 100644 --- a/github/enterprise_billing_cost_centers_test.go +++ b/github/enterprise_billing_cost_centers_test.go @@ -352,10 +352,10 @@ func TestEnterpriseService_DeleteCostCenter(t *testing.T) { } want := &DeleteCostCenterResponse{ - Message: Ptr("Cost center successfully deleted."), - ID: Ptr("2eeb8ffe-6903-11ee-8c99-0242ac120002"), - Name: Ptr("Engineering Team"), - CostCenterState: Ptr("CostCenterArchived"), + Message: "Cost center successfully deleted.", + ID: "2eeb8ffe-6903-11ee-8c99-0242ac120002", + Name: "Engineering Team", + CostCenterState: "CostCenterArchived", } if !cmp.Equal(result, want) { t.Errorf("Enterprise.DeleteCostCenter returned %+v, want %+v", result, want) @@ -635,3 +635,24 @@ func TestCostCenterResourceRequest_Marshal(t *testing.T) { testJSONMarshal(t, u, want) } + +func TestDeleteCostCenterResponse_Marshal(t *testing.T) { + t.Parallel() + testJSONMarshal(t, &DeleteCostCenterResponse{}, `{"message":"","id":"","name":"","costCenterState":""}`) + + u := &DeleteCostCenterResponse{ + Message: "Cost center successfully deleted.", + ID: "2eeb8ffe-6903-11ee-8c99-0242ac120002", + Name: "Engineering Team", + CostCenterState: "CostCenterArchived", + } + + want := `{ + "message": "Cost center successfully deleted.", + "id": "2eeb8ffe-6903-11ee-8c99-0242ac120002", + "name": "Engineering Team", + "costCenterState": "CostCenterArchived" + }` + + testJSONMarshal(t, u, want) +} diff --git a/github/github-accessors.go b/github/github-accessors.go index 3569b8e5df2..b19e697291d 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -7094,38 +7094,6 @@ func (d *DeleteAnalysis) GetNextAnalysisURL() string { return *d.NextAnalysisURL } -// GetCostCenterState returns the CostCenterState field if it's non-nil, zero value otherwise. -func (d *DeleteCostCenterResponse) GetCostCenterState() string { - if d == nil || d.CostCenterState == nil { - return "" - } - return *d.CostCenterState -} - -// GetID returns the ID field if it's non-nil, zero value otherwise. -func (d *DeleteCostCenterResponse) GetID() string { - if d == nil || d.ID == nil { - return "" - } - return *d.ID -} - -// GetMessage returns the Message field if it's non-nil, zero value otherwise. -func (d *DeleteCostCenterResponse) GetMessage() string { - if d == nil || d.Message == nil { - return "" - } - return *d.Message -} - -// GetName returns the Name field if it's non-nil, zero value otherwise. -func (d *DeleteCostCenterResponse) GetName() string { - if d == nil || d.Name == nil { - return "" - } - return *d.Name -} - // GetInstallation returns the Installation field. func (d *DeleteEvent) GetInstallation() *Installation { if d == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index da3fdfc2944..12532980b6b 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -9264,50 +9264,6 @@ func TestDeleteAnalysis_GetNextAnalysisURL(tt *testing.T) { d.GetNextAnalysisURL() } -func TestDeleteCostCenterResponse_GetCostCenterState(tt *testing.T) { - tt.Parallel() - var zeroValue string - d := &DeleteCostCenterResponse{CostCenterState: &zeroValue} - d.GetCostCenterState() - d = &DeleteCostCenterResponse{} - d.GetCostCenterState() - d = nil - d.GetCostCenterState() -} - -func TestDeleteCostCenterResponse_GetID(tt *testing.T) { - tt.Parallel() - var zeroValue string - d := &DeleteCostCenterResponse{ID: &zeroValue} - d.GetID() - d = &DeleteCostCenterResponse{} - d.GetID() - d = nil - d.GetID() -} - -func TestDeleteCostCenterResponse_GetMessage(tt *testing.T) { - tt.Parallel() - var zeroValue string - d := &DeleteCostCenterResponse{Message: &zeroValue} - d.GetMessage() - d = &DeleteCostCenterResponse{} - d.GetMessage() - d = nil - d.GetMessage() -} - -func TestDeleteCostCenterResponse_GetName(tt *testing.T) { - tt.Parallel() - var zeroValue string - d := &DeleteCostCenterResponse{Name: &zeroValue} - d.GetName() - d = &DeleteCostCenterResponse{} - d.GetName() - d = nil - d.GetName() -} - func TestDeleteEvent_GetInstallation(tt *testing.T) { tt.Parallel() d := &DeleteEvent{}