MCPcopy Index your code
hub / github.com/google/go-github / TestOrganizationsService_Edit

Function TestOrganizationsService_Edit

github/orgs_test.go:263–306  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

261}
262
263func TestOrganizationsService_Edit(t *testing.T) {
264 t.Parallel()
265 client, mux, _ := setup(t)
266
267 input := &Organization{Login: Ptr("l")}
268
269 mux.HandleFunc("/orgs/o", func(w http.ResponseWriter, r *http.Request) {
270 var v *Organization
271 assertNilError(t, json.NewDecoder(r.Body).Decode(&v))
272
273 testHeader(t, r, "Accept", mediaTypeMemberAllowedRepoCreationTypePreview)
274 testMethod(t, r, "PATCH")
275 if !cmp.Equal(v, input) {
276 t.Errorf("Request body = %+v, want %+v", v, input)
277 }
278
279 fmt.Fprint(w, `{"id":1}`)
280 })
281
282 ctx := t.Context()
283 org, _, err := client.Organizations.Edit(ctx, "o", input)
284 if err != nil {
285 t.Errorf("Organizations.Edit returned error: %v", err)
286 }
287
288 want := &Organization{ID: Ptr(int64(1))}
289 if !cmp.Equal(org, want) {
290 t.Errorf("Organizations.Edit returned %+v, want %+v", org, want)
291 }
292
293 const methodName = "Edit"
294 testBadOptions(t, methodName, func() (err error) {
295 _, _, err = client.Organizations.Edit(ctx, "\n", input)
296 return err
297 })
298
299 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
300 got, resp, err := client.Organizations.Edit(ctx, "o", input)
301 if got != nil {
302 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
303 }
304 return resp, err
305 })
306}
307
308func TestOrganizationsService_Edit_invalidOrg(t *testing.T) {
309 t.Parallel()

Callers

nothing calls this directly

Calls 9

testHeaderFunction · 0.85
testMethodFunction · 0.85
testBadOptionsFunction · 0.85
EqualMethod · 0.80
setupFunction · 0.70
PtrFunction · 0.70
assertNilErrorFunction · 0.70
EditMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…