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

Function TestIssuesService_ListLabels

github/issues_labels_test.go:16–51  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14)
15
16func TestIssuesService_ListLabels(t *testing.T) {
17 t.Parallel()
18 client, mux, _ := setup(t)
19
20 mux.HandleFunc("/repos/o/r/labels", func(w http.ResponseWriter, r *http.Request) {
21 testMethod(t, r, "GET")
22 testFormValues(t, r, values{"page": "2"})
23 fmt.Fprint(w, `[{"name": "a"},{"name": "b"}]`)
24 })
25
26 opt := &ListOptions{Page: 2}
27 ctx := t.Context()
28 labels, _, err := client.Issues.ListLabels(ctx, "o", "r", opt)
29 if err != nil {
30 t.Errorf("Issues.ListLabels returned error: %v", err)
31 }
32
33 want := []*Label{{Name: Ptr("a")}, {Name: Ptr("b")}}
34 if !cmp.Equal(labels, want) {
35 t.Errorf("Issues.ListLabels returned %+v, want %+v", labels, want)
36 }
37
38 const methodName = "ListLabels"
39 testBadOptions(t, methodName, func() (err error) {
40 _, _, err = client.Issues.ListLabels(ctx, "\n", "\n", opt)
41 return err
42 })
43
44 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
45 got, resp, err := client.Issues.ListLabels(ctx, "o", "r", opt)
46 if got != nil {
47 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
48 }
49 return resp, err
50 })
51}
52
53func TestIssuesService_ListLabels_invalidOwner(t *testing.T) {
54 t.Parallel()

Callers

nothing calls this directly

Calls 8

testMethodFunction · 0.85
testFormValuesFunction · 0.85
testBadOptionsFunction · 0.85
ListLabelsMethod · 0.80
EqualMethod · 0.80
setupFunction · 0.70
PtrFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…