From 8cf0e07371ea20c7251fed2f65f21e7aee7aea2b Mon Sep 17 00:00:00 2001 From: Ali Date: Thu, 29 Dec 2022 01:28:10 +0500 Subject: [PATCH] asked changes done --- github/actions_cache.go | 12 +++++----- github/actions_cache_test.go | 4 ++-- github/github-accessors.go | 32 ++++++++++++++++++++++++++ github/github-accessors_test.go | 40 +++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 8 deletions(-) diff --git a/github/actions_cache.go b/github/actions_cache.go index 2a51104cabe..9592d9ab62f 100644 --- a/github/actions_cache.go +++ b/github/actions_cache.go @@ -52,8 +52,8 @@ type ActionsCacheUsageList struct { // // GitHub API docs: https://docs.github.com/en/rest/actions/cache?apiVersion=2022-11-28#get-github-actions-cache-usage-for-an-enterprise type TotalCacheUsage struct { - TotalActiveCacheUsageSizeInBytes int64 `json:"total_active_caches_size_in_bytes"` - TotalActiveCachesCount int `json:"total_active_caches_count"` + TotalActiveCachesUsageSizeInBytes int64 `json:"total_active_caches_size_in_bytes"` + TotalActiveCachesCount int `json:"total_active_caches_count"` } // ActionsCacheListOptions represents a list of all possible optional Query parameters for ListCaches method. @@ -64,12 +64,12 @@ type ActionsCacheListOptions struct { // The Git reference for the results you want to list. // The ref for a branch can be formatted either as refs/heads/ // or simply . To reference a pull request use refs/pull//merge - Ref string `url:"ref,omitempty"` - Key string `url:"key,omitempty"` + Ref *string `url:"ref,omitempty"` + Key *string `url:"key,omitempty"` // Can be one of: "created_at", "last_accessed_at", "size_in_bytes". Default: "last_accessed_at" - Sort string `url:"sort,omitempty"` + Sort *string `url:"sort,omitempty"` // Can be one of: "asc", "desc" Default: desc - Direction string `url:"direction,omitempty"` + Direction *string `url:"direction,omitempty"` } // ListCaches lists the GitHub Actions caches for a repository. diff --git a/github/actions_cache_test.go b/github/actions_cache_test.go index a827b71a1d8..b72d5cb8284 100644 --- a/github/actions_cache_test.go +++ b/github/actions_cache_test.go @@ -394,7 +394,7 @@ func TestActionsService_GetCacheUsageForOrg(t *testing.T) { t.Errorf("Actions.GetTotalCacheUsageForOrg returned error: %v", err) } - want := &TotalCacheUsage{TotalActiveCacheUsageSizeInBytes: 1000, TotalActiveCachesCount: 1} + want := &TotalCacheUsage{TotalActiveCachesUsageSizeInBytes: 1000, TotalActiveCachesCount: 1} if !cmp.Equal(cache, want) { t.Errorf("Actions.GetTotalCacheUsageForOrg returned %+v, want %+v", cache, want) } @@ -465,7 +465,7 @@ func TestActionsService_GetCacheUsageForEnterprise(t *testing.T) { t.Errorf("Actions.GetTotalCacheUsageForEnterprise returned error: %v", err) } - want := &TotalCacheUsage{TotalActiveCacheUsageSizeInBytes: 1000, TotalActiveCachesCount: 1} + want := &TotalCacheUsage{TotalActiveCachesUsageSizeInBytes: 1000, TotalActiveCachesCount: 1} if !cmp.Equal(cache, want) { t.Errorf("Actions.GetTotalCacheUsageForEnterprise returned %+v, want %+v", cache, want) } diff --git a/github/github-accessors.go b/github/github-accessors.go index d823d630ad7..9311f3adfd3 100644 --- a/github/github-accessors.go +++ b/github/github-accessors.go @@ -94,6 +94,38 @@ func (a *ActionsCache) GetVersion() string { return *a.Version } +// GetDirection returns the Direction field if it's non-nil, zero value otherwise. +func (a *ActionsCacheListOptions) GetDirection() string { + if a == nil || a.Direction == nil { + return "" + } + return *a.Direction +} + +// GetKey returns the Key field if it's non-nil, zero value otherwise. +func (a *ActionsCacheListOptions) GetKey() string { + if a == nil || a.Key == nil { + return "" + } + return *a.Key +} + +// GetRef returns the Ref field if it's non-nil, zero value otherwise. +func (a *ActionsCacheListOptions) GetRef() string { + if a == nil || a.Ref == nil { + return "" + } + return *a.Ref +} + +// GetSort returns the Sort field if it's non-nil, zero value otherwise. +func (a *ActionsCacheListOptions) GetSort() string { + if a == nil || a.Sort == nil { + return "" + } + return *a.Sort +} + // GetAllowedActions returns the AllowedActions field if it's non-nil, zero value otherwise. func (a *ActionsPermissions) GetAllowedActions() string { if a == nil || a.AllowedActions == nil { diff --git a/github/github-accessors_test.go b/github/github-accessors_test.go index a279fb2b25e..d0151d40ed1 100644 --- a/github/github-accessors_test.go +++ b/github/github-accessors_test.go @@ -115,6 +115,46 @@ func TestActionsCache_GetVersion(tt *testing.T) { a.GetVersion() } +func TestActionsCacheListOptions_GetDirection(tt *testing.T) { + var zeroValue string + a := &ActionsCacheListOptions{Direction: &zeroValue} + a.GetDirection() + a = &ActionsCacheListOptions{} + a.GetDirection() + a = nil + a.GetDirection() +} + +func TestActionsCacheListOptions_GetKey(tt *testing.T) { + var zeroValue string + a := &ActionsCacheListOptions{Key: &zeroValue} + a.GetKey() + a = &ActionsCacheListOptions{} + a.GetKey() + a = nil + a.GetKey() +} + +func TestActionsCacheListOptions_GetRef(tt *testing.T) { + var zeroValue string + a := &ActionsCacheListOptions{Ref: &zeroValue} + a.GetRef() + a = &ActionsCacheListOptions{} + a.GetRef() + a = nil + a.GetRef() +} + +func TestActionsCacheListOptions_GetSort(tt *testing.T) { + var zeroValue string + a := &ActionsCacheListOptions{Sort: &zeroValue} + a.GetSort() + a = &ActionsCacheListOptions{} + a.GetSort() + a = nil + a.GetSort() +} + func TestActionsPermissions_GetAllowedActions(tt *testing.T) { var zeroValue string a := &ActionsPermissions{AllowedActions: &zeroValue}