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

Function TestSearchService_Repositories

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

Source from the content-addressed store, hash-verified

15)
16
17func TestSearchService_Repositories(t *testing.T) {
18 t.Parallel()
19 client, mux, _ := setup(t)
20
21 mux.HandleFunc("/search/repositories", func(w http.ResponseWriter, r *http.Request) {
22 testMethod(t, r, "GET")
23 testFormValues(t, r, values{
24 "q": "blah",
25 "sort": "forks",
26 "order": "desc",
27 "page": "2",
28 "per_page": "2",
29 })
30
31 fmt.Fprint(w, `{"total_count": 4, "incomplete_results": false, "items": [{"id":1},{"id":2}]}`)
32 })
33
34 opts := &SearchOptions{Sort: "forks", Order: "desc", ListOptions: ListOptions{Page: 2, PerPage: 2}}
35 ctx := t.Context()
36 result, _, err := client.Search.Repositories(ctx, "blah", opts)
37 if err != nil {
38 t.Errorf("Search.Repositories returned error: %v", err)
39 }
40
41 want := &RepositoriesSearchResult{
42 Total: Ptr(4),
43 IncompleteResults: Ptr(false),
44 Repositories: []*Repository{{ID: Ptr(int64(1))}, {ID: Ptr(int64(2))}},
45 }
46 if !cmp.Equal(result, want) {
47 t.Errorf("Search.Repositories returned %+v, want %+v", result, want)
48 }
49 const methodName = "Repositories"
50 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
51 got, resp, err := client.Search.Repositories(ctx, "blah", opts)
52 if got != nil {
53 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
54 }
55 return resp, err
56 })
57}
58
59func TestSearchService_Repositories_coverage(t *testing.T) {
60 t.Parallel()

Callers

nothing calls this directly

Calls 7

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