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

Function TestIssuesService_Create

github/issues_test.go:297–338  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

295}
296
297func TestIssuesService_Create(t *testing.T) {
298 t.Parallel()
299 client, mux, _ := setup(t)
300
301 input := &IssueRequest{
302 Title: Ptr("t"),
303 Body: Ptr("b"),
304 Assignee: Ptr("a"),
305 Labels: &[]string{"l1", "l2"},
306 }
307
308 mux.HandleFunc("/repos/o/r/issues", func(w http.ResponseWriter, r *http.Request) {
309 testMethod(t, r, "POST")
310 testJSONBody(t, r, input)
311 fmt.Fprint(w, `{"number":1}`)
312 })
313
314 ctx := t.Context()
315 issue, _, err := client.Issues.Create(ctx, "o", "r", input)
316 if err != nil {
317 t.Errorf("Issues.Create returned error: %v", err)
318 }
319
320 want := &Issue{Number: Ptr(1)}
321 if !cmp.Equal(issue, want) {
322 t.Errorf("Issues.Create returned %+v, want %+v", issue, want)
323 }
324
325 const methodName = "Create"
326 testBadOptions(t, methodName, func() (err error) {
327 _, _, err = client.Issues.Create(ctx, "\n", "\n", input)
328 return err
329 })
330
331 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
332 got, resp, err := client.Issues.Create(ctx, "o", "r", input)
333 if got != nil {
334 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
335 }
336 return resp, err
337 })
338}
339
340func TestIssuesService_Create_invalidOwner(t *testing.T) {
341 t.Parallel()

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…