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

Function TestSearchService_Topics

github/search_test.go:152–190  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

150}
151
152func TestSearchService_Topics(t *testing.T) {
153 t.Parallel()
154 client, mux, _ := setup(t)
155
156 mux.HandleFunc("/search/topics", func(w http.ResponseWriter, r *http.Request) {
157 testMethod(t, r, "GET")
158 testFormValues(t, r, values{
159 "q": "blah",
160 "page": "2",
161 "per_page": "2",
162 })
163
164 fmt.Fprint(w, `{"total_count": 4, "incomplete_results": false, "items": [{"name":"blah"},{"name":"blahblah"}]}`)
165 })
166
167 opts := &SearchOptions{ListOptions: ListOptions{Page: 2, PerPage: 2}}
168 ctx := t.Context()
169 result, _, err := client.Search.Topics(ctx, "blah", opts)
170 if err != nil {
171 t.Errorf("Search.Topics returned error: %v", err)
172 }
173
174 want := &TopicsSearchResult{
175 Total: Ptr(4),
176 IncompleteResults: Ptr(false),
177 Topics: []*TopicResult{{Name: Ptr("blah")}, {Name: Ptr("blahblah")}},
178 }
179 if !cmp.Equal(result, want) {
180 t.Errorf("Search.Topics returned %+v, want %+v", result, want)
181 }
182 const methodName = "Topics"
183 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
184 got, resp, err := client.Search.Topics(ctx, "blah", opts)
185 if got != nil {
186 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
187 }
188 return resp, err
189 })
190}
191
192func TestSearchService_Topics_coverage(t *testing.T) {
193 t.Parallel()

Callers

nothing calls this directly

Calls 7

testMethodFunction · 0.85
testFormValuesFunction · 0.85
TopicsMethod · 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…