...
1
2
3
4
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 TestOrganizationsService_ListCustomRepoRoles(t *testing.T) {
18 client, mux, _, teardown := setup()
19 defer teardown()
20
21 mux.HandleFunc("/orgs/o/custom_roles", func(w http.ResponseWriter, r *http.Request) {
22 testMethod(t, r, "GET")
23 fmt.Fprint(w, `{"total_count": 1, "custom_roles": [{ "id": 1, "name": "Developer"}]}`)
24 })
25
26 ctx := context.Background()
27 apps, _, err := client.Organizations.ListCustomRepoRoles(ctx, "o")
28 if err != nil {
29 t.Errorf("Organizations.ListCustomRepoRoles returned error: %v", err)
30 }
31
32 want := &OrganizationCustomRepoRoles{TotalCount: Int(1), CustomRepoRoles: []*CustomRepoRoles{{ID: Int64(1), Name: String("Developer")}}}
33 if !cmp.Equal(apps, want) {
34 t.Errorf("Organizations.ListCustomRepoRoles returned %+v, want %+v", apps, want)
35 }
36
37 const methodName = "ListCustomRepoRoles"
38 testBadOptions(t, methodName, func() (err error) {
39 _, _, err = client.Organizations.ListCustomRepoRoles(ctx, "\no")
40 return err
41 })
42
43 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
44 got, resp, err := client.Organizations.ListCustomRepoRoles(ctx, "o")
45 if got != nil {
46 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
47 }
48 return resp, err
49 })
50 }
51
View as plain text