github.com/google/go-github/v42@v42.0.0/github/actions_runner_groups_test.go (about)

     1  // Copyright 2021 The go-github AUTHORS. All rights reserved.
     2  //
     3  // Use of this source code is governed by a BSD-style
     4  // license that can be found in the LICENSE file.
     5  
     6  package github
     7  
     8  import (
     9  	"context"
    10  	"fmt"
    11  	"net/http"
    12  	"testing"
    13  
    14  	"github.com/google/go-cmp/cmp"
    15  )
    16  
    17  func TestActionsService_ListOrganizationRunnerGroups(t *testing.T) {
    18  	client, mux, _, teardown := setup()
    19  	defer teardown()
    20  
    21  	mux.HandleFunc("/orgs/o/actions/runner-groups", func(w http.ResponseWriter, r *http.Request) {
    22  		testMethod(t, r, "GET")
    23  		testFormValues(t, r, values{"per_page": "2", "page": "2"})
    24  		fmt.Fprint(w, `{"total_count":3,"runner_groups":[{"id":1,"name":"Default","visibility":"all","default":true,"runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/1/runners","inherited":false,"allows_public_repositories":true},{"id":2,"name":"octo-runner-group","visibility":"selected","default":false,"selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories","runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners","inherited":true,"allows_public_repositories":true},{"id":3,"name":"expensive-hardware","visibility":"private","default":false,"runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/3/runners","inherited":false,"allows_public_repositories":true}]}`)
    25  	})
    26  
    27  	opts := &ListOptions{Page: 2, PerPage: 2}
    28  	ctx := context.Background()
    29  	groups, _, err := client.Actions.ListOrganizationRunnerGroups(ctx, "o", opts)
    30  	if err != nil {
    31  		t.Errorf("Actions.ListOrganizationRunnerGroups returned error: %v", err)
    32  	}
    33  
    34  	want := &RunnerGroups{
    35  		TotalCount: 3,
    36  		RunnerGroups: []*RunnerGroup{
    37  			{ID: Int64(1), Name: String("Default"), Visibility: String("all"), Default: Bool(true), RunnersURL: String("https://api.github.com/orgs/octo-org/actions/runner_groups/1/runners"), Inherited: Bool(false), AllowsPublicRepositories: Bool(true)},
    38  			{ID: Int64(2), Name: String("octo-runner-group"), Visibility: String("selected"), Default: Bool(false), SelectedRepositoriesURL: String("https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories"), RunnersURL: String("https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners"), Inherited: Bool(true), AllowsPublicRepositories: Bool(true)},
    39  			{ID: Int64(3), Name: String("expensive-hardware"), Visibility: String("private"), Default: Bool(false), RunnersURL: String("https://api.github.com/orgs/octo-org/actions/runner_groups/3/runners"), Inherited: Bool(false), AllowsPublicRepositories: Bool(true)},
    40  		},
    41  	}
    42  	if !cmp.Equal(groups, want) {
    43  		t.Errorf("Actions.ListOrganizationRunnerGroups returned %+v, want %+v", groups, want)
    44  	}
    45  
    46  	const methodName = "ListOrganizationRunnerGroups"
    47  	testBadOptions(t, methodName, func() (err error) {
    48  		_, _, err = client.Actions.ListOrganizationRunnerGroups(ctx, "\n", opts)
    49  		return err
    50  	})
    51  
    52  	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
    53  		got, resp, err := client.Actions.ListOrganizationRunnerGroups(ctx, "o", opts)
    54  		if got != nil {
    55  			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
    56  		}
    57  		return resp, err
    58  	})
    59  }
    60  
    61  func TestActionsService_GetOrganizationRunnerGroup(t *testing.T) {
    62  	client, mux, _, teardown := setup()
    63  	defer teardown()
    64  
    65  	mux.HandleFunc("/orgs/o/actions/runner-groups/2", func(w http.ResponseWriter, r *http.Request) {
    66  		testMethod(t, r, "GET")
    67  		fmt.Fprint(w, `{"id":2,"name":"octo-runner-group","visibility":"selected","default":false,"selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories","runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners","inherited":false,"allows_public_repositories":true}`)
    68  	})
    69  
    70  	ctx := context.Background()
    71  	group, _, err := client.Actions.GetOrganizationRunnerGroup(ctx, "o", 2)
    72  	if err != nil {
    73  		t.Errorf("Actions.ListOrganizationRunnerGroups returned error: %v", err)
    74  	}
    75  
    76  	want := &RunnerGroup{
    77  		ID:                       Int64(2),
    78  		Name:                     String("octo-runner-group"),
    79  		Visibility:               String("selected"),
    80  		Default:                  Bool(false),
    81  		SelectedRepositoriesURL:  String("https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories"),
    82  		RunnersURL:               String("https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners"),
    83  		Inherited:                Bool(false),
    84  		AllowsPublicRepositories: Bool(true),
    85  	}
    86  
    87  	if !cmp.Equal(group, want) {
    88  		t.Errorf("Actions.GetOrganizationRunnerGroup returned %+v, want %+v", group, want)
    89  	}
    90  
    91  	const methodName = "GetOrganizationRunnerGroup"
    92  	testBadOptions(t, methodName, func() (err error) {
    93  		_, _, err = client.Actions.GetOrganizationRunnerGroup(ctx, "\n", 2)
    94  		return err
    95  	})
    96  
    97  	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
    98  		got, resp, err := client.Actions.GetOrganizationRunnerGroup(ctx, "o", 2)
    99  		if got != nil {
   100  			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
   101  		}
   102  		return resp, err
   103  	})
   104  }
   105  
   106  func TestActionsService_DeleteOrganizationRunnerGroup(t *testing.T) {
   107  	client, mux, _, teardown := setup()
   108  	defer teardown()
   109  
   110  	mux.HandleFunc("/orgs/o/actions/runner-groups/2", func(w http.ResponseWriter, r *http.Request) {
   111  		testMethod(t, r, "DELETE")
   112  	})
   113  
   114  	ctx := context.Background()
   115  	_, err := client.Actions.DeleteOrganizationRunnerGroup(ctx, "o", 2)
   116  	if err != nil {
   117  		t.Errorf("Actions.DeleteOrganizationRunnerGroup returned error: %v", err)
   118  	}
   119  
   120  	const methodName = "DeleteOrganizationRunnerGroup"
   121  	testBadOptions(t, methodName, func() (err error) {
   122  		_, err = client.Actions.DeleteOrganizationRunnerGroup(ctx, "\n", 2)
   123  		return err
   124  	})
   125  
   126  	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
   127  		return client.Actions.DeleteOrganizationRunnerGroup(ctx, "o", 2)
   128  	})
   129  }
   130  
   131  func TestActionsService_CreateOrganizationRunnerGroup(t *testing.T) {
   132  	client, mux, _, teardown := setup()
   133  	defer teardown()
   134  
   135  	mux.HandleFunc("/orgs/o/actions/runner-groups", func(w http.ResponseWriter, r *http.Request) {
   136  		testMethod(t, r, "POST")
   137  		fmt.Fprint(w, `{"id":2,"name":"octo-runner-group","visibility":"selected","default":false,"selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories","runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners","inherited":false,"allows_public_repositories":true}`)
   138  	})
   139  
   140  	ctx := context.Background()
   141  	req := CreateRunnerGroupRequest{
   142  		Name:                     String("octo-runner-group"),
   143  		Visibility:               String("selected"),
   144  		AllowsPublicRepositories: Bool(true),
   145  	}
   146  	group, _, err := client.Actions.CreateOrganizationRunnerGroup(ctx, "o", req)
   147  	if err != nil {
   148  		t.Errorf("Actions.CreateOrganizationRunnerGroup returned error: %v", err)
   149  	}
   150  
   151  	want := &RunnerGroup{
   152  		ID:                       Int64(2),
   153  		Name:                     String("octo-runner-group"),
   154  		Visibility:               String("selected"),
   155  		Default:                  Bool(false),
   156  		SelectedRepositoriesURL:  String("https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories"),
   157  		RunnersURL:               String("https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners"),
   158  		Inherited:                Bool(false),
   159  		AllowsPublicRepositories: Bool(true),
   160  	}
   161  
   162  	if !cmp.Equal(group, want) {
   163  		t.Errorf("Actions.CreateOrganizationRunnerGroup returned %+v, want %+v", group, want)
   164  	}
   165  
   166  	const methodName = "CreateOrganizationRunnerGroup"
   167  	testBadOptions(t, methodName, func() (err error) {
   168  		_, _, err = client.Actions.CreateOrganizationRunnerGroup(ctx, "\n", req)
   169  		return err
   170  	})
   171  
   172  	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
   173  		got, resp, err := client.Actions.CreateOrganizationRunnerGroup(ctx, "o", req)
   174  		if got != nil {
   175  			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
   176  		}
   177  		return resp, err
   178  	})
   179  }
   180  
   181  func TestActionsService_UpdateOrganizationRunnerGroup(t *testing.T) {
   182  	client, mux, _, teardown := setup()
   183  	defer teardown()
   184  
   185  	mux.HandleFunc("/orgs/o/actions/runner-groups/2", func(w http.ResponseWriter, r *http.Request) {
   186  		testMethod(t, r, "PATCH")
   187  		fmt.Fprint(w, `{"id":2,"name":"octo-runner-group","visibility":"selected","default":false,"selected_repositories_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories","runners_url":"https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners","inherited":false,"allows_public_repositories":true}`)
   188  	})
   189  
   190  	ctx := context.Background()
   191  	req := UpdateRunnerGroupRequest{
   192  		Name:                     String("octo-runner-group"),
   193  		Visibility:               String("selected"),
   194  		AllowsPublicRepositories: Bool(true),
   195  	}
   196  	group, _, err := client.Actions.UpdateOrganizationRunnerGroup(ctx, "o", 2, req)
   197  	if err != nil {
   198  		t.Errorf("Actions.UpdateOrganizationRunnerGroup returned error: %v", err)
   199  	}
   200  
   201  	want := &RunnerGroup{
   202  		ID:                       Int64(2),
   203  		Name:                     String("octo-runner-group"),
   204  		Visibility:               String("selected"),
   205  		Default:                  Bool(false),
   206  		SelectedRepositoriesURL:  String("https://api.github.com/orgs/octo-org/actions/runner_groups/2/repositories"),
   207  		RunnersURL:               String("https://api.github.com/orgs/octo-org/actions/runner_groups/2/runners"),
   208  		Inherited:                Bool(false),
   209  		AllowsPublicRepositories: Bool(true),
   210  	}
   211  
   212  	if !cmp.Equal(group, want) {
   213  		t.Errorf("Actions.UpdateOrganizationRunnerGroup returned %+v, want %+v", group, want)
   214  	}
   215  
   216  	const methodName = "UpdateOrganizationRunnerGroup"
   217  	testBadOptions(t, methodName, func() (err error) {
   218  		_, _, err = client.Actions.UpdateOrganizationRunnerGroup(ctx, "\n", 2, req)
   219  		return err
   220  	})
   221  
   222  	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
   223  		got, resp, err := client.Actions.UpdateOrganizationRunnerGroup(ctx, "o", 2, req)
   224  		if got != nil {
   225  			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
   226  		}
   227  		return resp, err
   228  	})
   229  }
   230  
   231  func TestActionsService_ListRepositoryAccessRunnerGroup(t *testing.T) {
   232  	client, mux, _, teardown := setup()
   233  	defer teardown()
   234  
   235  	mux.HandleFunc("/orgs/o/actions/runner-groups/2/repositories", func(w http.ResponseWriter, r *http.Request) {
   236  		testMethod(t, r, "GET")
   237  		testFormValues(t, r, values{"per_page": "1", "page": "1"})
   238  		fmt.Fprint(w, `{"total_count": 1, "repositories": [{"id": 43, "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5", "name": "Hello-World", "full_name": "octocat/Hello-World"}]}`)
   239  	})
   240  
   241  	ctx := context.Background()
   242  	opts := &ListOptions{Page: 1, PerPage: 1}
   243  	groups, _, err := client.Actions.ListRepositoryAccessRunnerGroup(ctx, "o", 2, opts)
   244  	if err != nil {
   245  		t.Errorf("Actions.ListRepositoryAccessRunnerGroup returned error: %v", err)
   246  	}
   247  
   248  	want := &ListRepositories{
   249  		TotalCount: Int(1),
   250  		Repositories: []*Repository{
   251  			{ID: Int64(43), NodeID: String("MDEwOlJlcG9zaXRvcnkxMjk2MjY5"), Name: String("Hello-World"), FullName: String("octocat/Hello-World")},
   252  		},
   253  	}
   254  	if !cmp.Equal(groups, want) {
   255  		t.Errorf("Actions.ListRepositoryAccessRunnerGroup returned %+v, want %+v", groups, want)
   256  	}
   257  
   258  	const methodName = "ListRepositoryAccessRunnerGroup"
   259  	testBadOptions(t, methodName, func() (err error) {
   260  		_, _, err = client.Actions.ListRepositoryAccessRunnerGroup(ctx, "\n", 2, opts)
   261  		return err
   262  	})
   263  
   264  	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
   265  		got, resp, err := client.Actions.ListRepositoryAccessRunnerGroup(ctx, "o", 2, opts)
   266  		if got != nil {
   267  			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
   268  		}
   269  		return resp, err
   270  	})
   271  }
   272  
   273  func TestActionsService_SetRepositoryAccessRunnerGroup(t *testing.T) {
   274  	client, mux, _, teardown := setup()
   275  	defer teardown()
   276  
   277  	mux.HandleFunc("/orgs/o/actions/runner-groups/2/repositories", func(w http.ResponseWriter, r *http.Request) {
   278  		testMethod(t, r, "PUT")
   279  	})
   280  
   281  	req := SetRepoAccessRunnerGroupRequest{
   282  		SelectedRepositoryIDs: []int64{
   283  			1,
   284  			2,
   285  		},
   286  	}
   287  
   288  	ctx := context.Background()
   289  	_, err := client.Actions.SetRepositoryAccessRunnerGroup(ctx, "o", 2, req)
   290  	if err != nil {
   291  		t.Errorf("Actions.SetRepositoryAccessRunnerGroup returned error: %v", err)
   292  	}
   293  
   294  	const methodName = "SetRepositoryAccessRunnerGroup"
   295  	testBadOptions(t, methodName, func() (err error) {
   296  		_, err = client.Actions.SetRepositoryAccessRunnerGroup(ctx, "\n", 2, req)
   297  		return err
   298  	})
   299  
   300  	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
   301  		return client.Actions.SetRepositoryAccessRunnerGroup(ctx, "o", 2, req)
   302  	})
   303  }
   304  
   305  func TestActionsService_AddRepositoryAccessRunnerGroup(t *testing.T) {
   306  	client, mux, _, teardown := setup()
   307  	defer teardown()
   308  
   309  	mux.HandleFunc("/orgs/o/actions/runner-groups/2/repositories/42", func(w http.ResponseWriter, r *http.Request) {
   310  		testMethod(t, r, "PUT")
   311  	})
   312  
   313  	ctx := context.Background()
   314  	_, err := client.Actions.AddRepositoryAccessRunnerGroup(ctx, "o", 2, 42)
   315  	if err != nil {
   316  		t.Errorf("Actions.AddRepositoryAccessRunnerGroup returned error: %v", err)
   317  	}
   318  
   319  	const methodName = "AddRepositoryAccessRunnerGroup"
   320  	testBadOptions(t, methodName, func() (err error) {
   321  		_, err = client.Actions.AddRepositoryAccessRunnerGroup(ctx, "\n", 2, 42)
   322  		return err
   323  	})
   324  
   325  	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
   326  		return client.Actions.AddRepositoryAccessRunnerGroup(ctx, "o", 2, 42)
   327  	})
   328  }
   329  
   330  func TestActionsService_RemoveRepositoryAccessRunnerGroup(t *testing.T) {
   331  	client, mux, _, teardown := setup()
   332  	defer teardown()
   333  
   334  	mux.HandleFunc("/orgs/o/actions/runner-groups/2/repositories/42", func(w http.ResponseWriter, r *http.Request) {
   335  		testMethod(t, r, "DELETE")
   336  	})
   337  
   338  	ctx := context.Background()
   339  	_, err := client.Actions.RemoveRepositoryAccessRunnerGroup(ctx, "o", 2, 42)
   340  	if err != nil {
   341  		t.Errorf("Actions.RemoveRepositoryAccessRunnerGroup returned error: %v", err)
   342  	}
   343  
   344  	const methodName = "RemoveRepositoryAccessRunnerGroup"
   345  	testBadOptions(t, methodName, func() (err error) {
   346  		_, err = client.Actions.RemoveRepositoryAccessRunnerGroup(ctx, "\n", 2, 42)
   347  		return err
   348  	})
   349  
   350  	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
   351  		return client.Actions.RemoveRepositoryAccessRunnerGroup(ctx, "o", 2, 42)
   352  	})
   353  }
   354  
   355  func TestActionsService_ListRunnerGroupRunners(t *testing.T) {
   356  	client, mux, _, teardown := setup()
   357  	defer teardown()
   358  
   359  	mux.HandleFunc("/orgs/o/actions/runner-groups/2/runners", func(w http.ResponseWriter, r *http.Request) {
   360  		testMethod(t, r, "GET")
   361  		testFormValues(t, r, values{"per_page": "2", "page": "2"})
   362  		fmt.Fprint(w, `{"total_count":2,"runners":[{"id":23,"name":"MBP","os":"macos","status":"online"},{"id":24,"name":"iMac","os":"macos","status":"offline"}]}`)
   363  	})
   364  
   365  	opts := &ListOptions{Page: 2, PerPage: 2}
   366  	ctx := context.Background()
   367  	runners, _, err := client.Actions.ListRunnerGroupRunners(ctx, "o", 2, opts)
   368  	if err != nil {
   369  		t.Errorf("Actions.ListRunnerGroupRunners returned error: %v", err)
   370  	}
   371  
   372  	want := &Runners{
   373  		TotalCount: 2,
   374  		Runners: []*Runner{
   375  			{ID: Int64(23), Name: String("MBP"), OS: String("macos"), Status: String("online")},
   376  			{ID: Int64(24), Name: String("iMac"), OS: String("macos"), Status: String("offline")},
   377  		},
   378  	}
   379  	if !cmp.Equal(runners, want) {
   380  		t.Errorf("Actions.ListRunnerGroupRunners returned %+v, want %+v", runners, want)
   381  	}
   382  
   383  	const methodName = "ListRunnerGroupRunners"
   384  	testBadOptions(t, methodName, func() (err error) {
   385  		_, _, err = client.Actions.ListRunnerGroupRunners(ctx, "\n", 2, opts)
   386  		return err
   387  	})
   388  
   389  	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
   390  		got, resp, err := client.Actions.ListRunnerGroupRunners(ctx, "o", 2, opts)
   391  		if got != nil {
   392  			t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
   393  		}
   394  		return resp, err
   395  	})
   396  }
   397  
   398  func TestActionsService_SetRunnerGroupRunners(t *testing.T) {
   399  	client, mux, _, teardown := setup()
   400  	defer teardown()
   401  
   402  	mux.HandleFunc("/orgs/o/actions/runner-groups/2/runners", func(w http.ResponseWriter, r *http.Request) {
   403  		testMethod(t, r, "PUT")
   404  	})
   405  
   406  	req := SetRunnerGroupRunnersRequest{
   407  		Runners: []int64{
   408  			1,
   409  			2,
   410  		},
   411  	}
   412  
   413  	ctx := context.Background()
   414  	_, err := client.Actions.SetRunnerGroupRunners(ctx, "o", 2, req)
   415  	if err != nil {
   416  		t.Errorf("Actions.SetRunnerGroupRunners returned error: %v", err)
   417  	}
   418  
   419  	const methodName = "SetRunnerGroupRunners"
   420  	testBadOptions(t, methodName, func() (err error) {
   421  		_, err = client.Actions.SetRunnerGroupRunners(ctx, "\n", 2, req)
   422  		return err
   423  	})
   424  
   425  	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
   426  		return client.Actions.SetRunnerGroupRunners(ctx, "o", 2, req)
   427  	})
   428  }
   429  
   430  func TestActionsService_AddRunnerGroupRunners(t *testing.T) {
   431  	client, mux, _, teardown := setup()
   432  	defer teardown()
   433  
   434  	mux.HandleFunc("/orgs/o/actions/runner-groups/2/runners/42", func(w http.ResponseWriter, r *http.Request) {
   435  		testMethod(t, r, "PUT")
   436  	})
   437  
   438  	ctx := context.Background()
   439  	_, err := client.Actions.AddRunnerGroupRunners(ctx, "o", 2, 42)
   440  	if err != nil {
   441  		t.Errorf("Actions.AddRunnerGroupRunners returned error: %v", err)
   442  	}
   443  
   444  	const methodName = "AddRunnerGroupRunners"
   445  	testBadOptions(t, methodName, func() (err error) {
   446  		_, err = client.Actions.AddRunnerGroupRunners(ctx, "\n", 2, 42)
   447  		return err
   448  	})
   449  
   450  	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
   451  		return client.Actions.AddRunnerGroupRunners(ctx, "o", 2, 42)
   452  	})
   453  }
   454  
   455  func TestActionsService_RemoveRunnerGroupRunners(t *testing.T) {
   456  	client, mux, _, teardown := setup()
   457  	defer teardown()
   458  
   459  	mux.HandleFunc("/orgs/o/actions/runner-groups/2/runners/42", func(w http.ResponseWriter, r *http.Request) {
   460  		testMethod(t, r, "DELETE")
   461  	})
   462  
   463  	ctx := context.Background()
   464  	_, err := client.Actions.RemoveRunnerGroupRunners(ctx, "o", 2, 42)
   465  	if err != nil {
   466  		t.Errorf("Actions.RemoveRunnerGroupRunners returned error: %v", err)
   467  	}
   468  
   469  	const methodName = "RemoveRunnerGroupRunners"
   470  	testBadOptions(t, methodName, func() (err error) {
   471  		_, err = client.Actions.RemoveRunnerGroupRunners(ctx, "\n", 2, 42)
   472  		return err
   473  	})
   474  
   475  	testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
   476  		return client.Actions.RemoveRunnerGroupRunners(ctx, "o", 2, 42)
   477  	})
   478  }
   479  
   480  func TestRunnerGroup_Marshal(t *testing.T) {
   481  	testJSONMarshal(t, &RunnerGroup{}, "{}")
   482  
   483  	u := &RunnerGroup{
   484  		ID:                       Int64(1),
   485  		Name:                     String("n"),
   486  		Visibility:               String("v"),
   487  		Default:                  Bool(true),
   488  		SelectedRepositoriesURL:  String("s"),
   489  		RunnersURL:               String("r"),
   490  		Inherited:                Bool(true),
   491  		AllowsPublicRepositories: Bool(true),
   492  	}
   493  
   494  	want := `{
   495  		"id": 1,
   496  		"name": "n",
   497  		"visibility": "v",
   498  		"default": true,
   499  		"selected_repositories_url": "s",
   500  		"runners_url": "r",
   501  		"inherited": true,
   502  		"allows_public_repositories": true
   503  	}`
   504  
   505  	testJSONMarshal(t, u, want)
   506  }
   507  
   508  func TestRunnerGroups_Marshal(t *testing.T) {
   509  	testJSONMarshal(t, &RunnerGroups{}, "{}")
   510  
   511  	u := &RunnerGroups{
   512  		TotalCount: int(1),
   513  		RunnerGroups: []*RunnerGroup{
   514  			{
   515  				ID:                       Int64(1),
   516  				Name:                     String("n"),
   517  				Visibility:               String("v"),
   518  				Default:                  Bool(true),
   519  				SelectedRepositoriesURL:  String("s"),
   520  				RunnersURL:               String("r"),
   521  				Inherited:                Bool(true),
   522  				AllowsPublicRepositories: Bool(true),
   523  			},
   524  		},
   525  	}
   526  
   527  	want := `{
   528  		"total_count": 1,
   529  		"runner_groups": [{
   530  			"id": 1,
   531  			"name": "n",
   532  			"visibility": "v",
   533  			"default": true,
   534  			"selected_repositories_url": "s",
   535  			"runners_url": "r",
   536  			"inherited": true,
   537  			"allows_public_repositories": true
   538  		}]		
   539  	}`
   540  
   541  	testJSONMarshal(t, u, want)
   542  }
   543  
   544  func TestCreateRunnerGroupRequest_Marshal(t *testing.T) {
   545  	testJSONMarshal(t, &CreateRunnerGroupRequest{}, "{}")
   546  
   547  	u := &CreateRunnerGroupRequest{
   548  		Name:                     String("n"),
   549  		Visibility:               String("v"),
   550  		SelectedRepositoryIDs:    []int64{1},
   551  		Runners:                  []int64{1},
   552  		AllowsPublicRepositories: Bool(true),
   553  	}
   554  
   555  	want := `{
   556  		"name": "n",
   557  		"visibility": "v",
   558  		"selected_repository_ids": [1],
   559  		"runners": [1],
   560  		"allows_public_repositories": true
   561  	}`
   562  
   563  	testJSONMarshal(t, u, want)
   564  }
   565  
   566  func TestUpdateRunnerGroupRequest_Marshal(t *testing.T) {
   567  	testJSONMarshal(t, &UpdateRunnerGroupRequest{}, "{}")
   568  
   569  	u := &UpdateRunnerGroupRequest{
   570  		Name:                     String("n"),
   571  		Visibility:               String("v"),
   572  		AllowsPublicRepositories: Bool(true),
   573  	}
   574  
   575  	want := `{
   576  		"name": "n",
   577  		"visibility": "v",
   578  		"allows_public_repositories": true
   579  	}`
   580  
   581  	testJSONMarshal(t, u, want)
   582  }
   583  
   584  func TestSetRepoAccessRunnerGroupRequest_Marshal(t *testing.T) {
   585  	testJSONMarshal(t, &SetRepoAccessRunnerGroupRequest{}, "{}")
   586  
   587  	u := &SetRepoAccessRunnerGroupRequest{
   588  		SelectedRepositoryIDs: []int64{1},
   589  	}
   590  
   591  	want := `{
   592  		"selected_repository_ids": [1]
   593  	}`
   594  
   595  	testJSONMarshal(t, u, want)
   596  }
   597  
   598  func TestSetRunnerGroupRunnersRequest_Marshal(t *testing.T) {
   599  	testJSONMarshal(t, &SetRunnerGroupRunnersRequest{}, "{}")
   600  
   601  	u := &SetRunnerGroupRunnersRequest{
   602  		Runners: []int64{1},
   603  	}
   604  
   605  	want := `{
   606  		"runners": [1]
   607  	}`
   608  
   609  	testJSONMarshal(t, u, want)
   610  }