MCPcopy Create free account
hub / github.com/google/go-github / TestLicensesService_List

Function TestLicensesService_List

github/licenses_test.go:112–148  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

110}
111
112func TestLicensesService_List(t *testing.T) {
113 t.Parallel()
114 client, mux, _ := setup(t)
115
116 mux.HandleFunc("/licenses", func(w http.ResponseWriter, r *http.Request) {
117 testMethod(t, r, "GET")
118 testFormValues(t, r, values{"featured": "true", "page": "2", "per_page": "20"})
119 fmt.Fprint(w, `[{"key":"mit","name":"MIT","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","featured":true}]`)
120 })
121
122 opts := &ListLicensesOptions{Featured: Ptr(true), ListOptions: ListOptions{Page: 2, PerPage: 20}}
123 ctx := t.Context()
124 licenses, _, err := client.Licenses.List(ctx, opts)
125 if err != nil {
126 t.Errorf("Licenses.List returned error: %v", err)
127 }
128
129 want := []*License{{
130 Key: Ptr("mit"),
131 Name: Ptr("MIT"),
132 SPDXID: Ptr("MIT"),
133 URL: Ptr("https://api.github.com/licenses/mit"),
134 Featured: Ptr(true),
135 }}
136 if !cmp.Equal(licenses, want) {
137 t.Errorf("Licenses.List returned %+v, want %+v", licenses, want)
138 }
139
140 const methodName = "List"
141 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
142 got, resp, err := client.Licenses.List(ctx, opts)
143 if got != nil {
144 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
145 }
146 return resp, err
147 })
148}
149
150func TestLicensesService_Get(t *testing.T) {
151 t.Parallel()

Callers

nothing calls this directly

Calls 7

testMethodFunction · 0.85
testFormValuesFunction · 0.85
EqualMethod · 0.80
setupFunction · 0.70
PtrFunction · 0.70
ListMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…