@@ -96,6 +96,84 @@ func TestOrganizationsService_ListCustomRepoRoles(t *testing.T) {
9696 })
9797}
9898
99+ func TestOrganizationsService_GetCustomRepoRole (t * testing.T ) {
100+ t .Parallel ()
101+ client , mux , _ := setup (t )
102+
103+ mux .HandleFunc ("/orgs/o/custom-repository-roles/1" , func (w http.ResponseWriter , r * http.Request ) {
104+ testMethod (t , r , "GET" )
105+ fmt .Fprint (w , `{
106+ "id": 1,
107+ "name": "Developer",
108+ "base_role": "write",
109+ "permissions": ["delete_alerts_code_scanning"],
110+ "organization": {
111+ "login": "l",
112+ "id": 1,
113+ "node_id": "n",
114+ "avatar_url": "a",
115+ "html_url": "h",
116+ "name": "n",
117+ "company": "c",
118+ "blog": "b",
119+ "location": "l",
120+ "email": "e"
121+ },
122+ "created_at": "2024-07-21T19:33:08Z",
123+ "updated_at": "2024-07-21T19:33:08Z"
124+ }` )
125+ })
126+
127+ ctx := context .Background ()
128+ role , _ , err := client .Organizations .GetCustomRepoRole (ctx , "o" , 1 )
129+ if err != nil {
130+ t .Errorf ("Organizations.GetCustomRepoRole returned error: %v" , err )
131+ }
132+
133+ want := & CustomRepoRoles {
134+ ID : Int64 (1 ),
135+ Name : String ("Developer" ),
136+ BaseRole : String ("write" ),
137+ Permissions : []string {"delete_alerts_code_scanning" },
138+ Org : & Organization {
139+ Login : String ("l" ),
140+ ID : Int64 (1 ),
141+ NodeID : String ("n" ),
142+ AvatarURL : String ("a" ),
143+ HTMLURL : String ("h" ),
144+ Name : String ("n" ),
145+ Company : String ("c" ),
146+ Blog : String ("b" ),
147+ Location : String ("l" ),
148+ Email : String ("e" ),
149+ },
150+ CreatedAt : & Timestamp {time .Date (2024 , time .July , 21 , 19 , 33 , 8 , 0 , time .UTC )},
151+ UpdatedAt : & Timestamp {time .Date (2024 , time .July , 21 , 19 , 33 , 8 , 0 , time .UTC )},
152+ }
153+ if ! cmp .Equal (role , want ) {
154+ t .Errorf ("Organizations.GetCustomRepoRole returned %+v, want %+v" , role , want )
155+ }
156+
157+ const methodName = "GetCustomRepoRole"
158+ testBadOptions (t , methodName , func () (err error ) {
159+ _ , _ , err = client .Organizations .GetCustomRepoRole (ctx , "\n o" , 1 )
160+ return err
161+ })
162+
163+ testBadOptions (t , methodName , func () (err error ) {
164+ _ , _ , err = client .Organizations .GetCustomRepoRole (ctx , "o" , - 1 )
165+ return err
166+ })
167+
168+ testNewRequestAndDoFailure (t , methodName , client , func () (* Response , error ) {
169+ got , resp , err := client .Organizations .GetCustomRepoRole (ctx , "o" , 1 )
170+ if got != nil {
171+ t .Errorf ("testNewRequestAndDoFailure %v = %#v, want nil" , methodName , got )
172+ }
173+ return resp , err
174+ })
175+ }
176+
99177func TestOrganizationsService_CreateCustomRepoRole (t * testing.T ) {
100178 t .Parallel ()
101179 client , mux , _ := setup (t )
0 commit comments