Skip to content

Commit

Permalink
feat!: Change enterprise runner to also use ListRunnersOptions (#3167)
Browse files Browse the repository at this point in the history
Fixes: #3166.

BREAKING-CHANGE: This changes `ListOptions` to  `ListRunnersOptions` in `EnterpriseService.ListRunners`.
  • Loading branch information
ponkio-o authored May 13, 2024
1 parent 51bedeb commit 4169a9c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion github/enterprise_actions_runners.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (s *EnterpriseService) CreateRegistrationToken(ctx context.Context, enterpr
// GitHub API docs: https://docs.github.com/enterprise-cloud@latest/rest/actions/self-hosted-runners#list-self-hosted-runners-for-an-enterprise
//
//meta:operation GET /enterprises/{enterprise}/actions/runners
func (s *EnterpriseService) ListRunners(ctx context.Context, enterprise string, opts *ListOptions) (*Runners, *Response, error) {
func (s *EnterpriseService) ListRunners(ctx context.Context, enterprise string, opts *ListRunnersOptions) (*Runners, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/runners", enterprise)
u, err := addOptions(u, opts)
if err != nil {
Expand Down
14 changes: 8 additions & 6 deletions github/enterprise_actions_runners_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,22 +106,24 @@ func TestEnterpriseService_ListRunners(t *testing.T) {

mux.HandleFunc("/enterprises/e/actions/runners", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testFormValues(t, r, values{"per_page": "2", "page": "2"})
fmt.Fprint(w, `{"total_count":2,"runners":[{"id":23,"name":"MBP","os":"macos","status":"online"},{"id":24,"name":"iMac","os":"macos","status":"offline"}]}`)
testFormValues(t, r, values{"name": "MBP", "per_page": "2", "page": "2"})
fmt.Fprint(w, `{"total_count":1,"runners":[{"id":23,"name":"MBP","os":"macos","status":"online"}]}`)
})

opts := &ListOptions{Page: 2, PerPage: 2}
opts := &ListRunnersOptions{
Name: String("MBP"),
ListOptions: ListOptions{Page: 2, PerPage: 2},
}
ctx := context.Background()
runners, _, err := client.Enterprise.ListRunners(ctx, "e", opts)
if err != nil {
t.Errorf("Enterprise.ListRunners returned error: %v", err)
}

want := &Runners{
TotalCount: 2,
TotalCount: 1,
Runners: []*Runner{
{ID: Int64(23), Name: String("MBP"), OS: String("macos"), Status: String("online")},
{ID: Int64(24), Name: String("iMac"), OS: String("macos"), Status: String("offline")},
},
}
if !cmp.Equal(runners, want) {
Expand All @@ -130,7 +132,7 @@ func TestEnterpriseService_ListRunners(t *testing.T) {

const methodName = "ListRunners"
testBadOptions(t, methodName, func() (err error) {
_, _, err = client.Enterprise.ListRunners(ctx, "\n", &ListOptions{})
_, _, err = client.Enterprise.ListRunners(ctx, "\n", &ListRunnersOptions{})
return err
})

Expand Down

0 comments on commit 4169a9c

Please sign in to comment.