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

Function TestPullRequestsService_Create

github/pulls_test.go:355–397  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

353}
354
355func TestPullRequestsService_Create(t *testing.T) {
356 t.Parallel()
357 client, mux, _ := setup(t)
358
359 input := &NewPullRequest{Title: Ptr("t")}
360
361 mux.HandleFunc("/repos/o/r/pulls", func(w http.ResponseWriter, r *http.Request) {
362 var v *NewPullRequest
363 assertNilError(t, json.NewDecoder(r.Body).Decode(&v))
364
365 testMethod(t, r, "POST")
366 if !cmp.Equal(v, input) {
367 t.Errorf("Request body = %+v, want %+v", v, input)
368 }
369
370 fmt.Fprint(w, `{"number":1}`)
371 })
372
373 ctx := t.Context()
374 pull, _, err := client.PullRequests.Create(ctx, "o", "r", input)
375 if err != nil {
376 t.Errorf("PullRequests.Create returned error: %v", err)
377 }
378
379 want := &PullRequest{Number: Ptr(1)}
380 if !cmp.Equal(pull, want) {
381 t.Errorf("PullRequests.Create returned %+v, want %+v", pull, want)
382 }
383
384 const methodName = "Create"
385 testBadOptions(t, methodName, func() (err error) {
386 _, _, err = client.PullRequests.Create(ctx, "\n", "\n", input)
387 return err
388 })
389
390 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
391 got, resp, err := client.PullRequests.Create(ctx, "o", "r", input)
392 if got != nil {
393 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
394 }
395 return resp, err
396 })
397}
398
399func TestPullRequestsService_Create_invalidOwner(t *testing.T) {
400 t.Parallel()

Callers

nothing calls this directly

Calls 8

testMethodFunction · 0.85
testBadOptionsFunction · 0.85
EqualMethod · 0.80
setupFunction · 0.70
PtrFunction · 0.70
assertNilErrorFunction · 0.70
CreateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…