Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Change enterprise runner to also use ListRunnersOptions #3167

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading