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

Function TestSearchService_Commits

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

Source from the content-addressed store, hash-verified

203}
204
205func TestSearchService_Commits(t *testing.T) {
206 t.Parallel()
207 client, mux, _ := setup(t)
208
209 mux.HandleFunc("/search/commits", func(w http.ResponseWriter, r *http.Request) {
210 testMethod(t, r, "GET")
211 testFormValues(t, r, values{
212 "q": "blah",
213 "sort": "author-date",
214 "order": "desc",
215 })
216
217 fmt.Fprint(w, `{"total_count": 4, "incomplete_results": false, "items": [{"sha":"random_hash1"},{"sha":"random_hash2"}]}`)
218 })
219
220 opts := &SearchOptions{Sort: "author-date", Order: "desc"}
221 ctx := t.Context()
222 result, _, err := client.Search.Commits(ctx, "blah", opts)
223 if err != nil {
224 t.Errorf("Search.Commits returned error: %v", err)
225 }
226
227 want := &CommitsSearchResult{
228 Total: Ptr(4),
229 IncompleteResults: Ptr(false),
230 Commits: []*CommitResult{{SHA: Ptr("random_hash1")}, {SHA: Ptr("random_hash2")}},
231 }
232 if !cmp.Equal(result, want) {
233 t.Errorf("Search.Commits returned %+v, want %+v", result, want)
234 }
235 const methodName = "Commits"
236 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
237 got, resp, err := client.Search.Commits(ctx, "blah", opts)
238 if got != nil {
239 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
240 }
241 return resp, err
242 })
243}
244
245func TestSearchService_Commits_coverage(t *testing.T) {
246 t.Parallel()

Callers

nothing calls this directly

Calls 7

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