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

Function TestRepositoriesService_ListByUser

github/repos_test.go:52–95  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

50}
51
52func TestRepositoriesService_ListByUser(t *testing.T) {
53 t.Parallel()
54 client, mux, _ := setup(t)
55
56 mux.HandleFunc("/users/u/repos", func(w http.ResponseWriter, r *http.Request) {
57 testMethod(t, r, "GET")
58 testFormValues(t, r, values{
59 "sort": "created",
60 "direction": "asc",
61 "page": "2",
62 })
63 fmt.Fprint(w, `[{"id":1}]`)
64 })
65
66 opt := &RepositoryListByUserOptions{
67 Sort: "created",
68 Direction: "asc",
69 ListOptions: ListOptions{Page: 2},
70 }
71 ctx := t.Context()
72 repos, _, err := client.Repositories.ListByUser(ctx, "u", opt)
73 if err != nil {
74 t.Errorf("Repositories.List returned error: %v", err)
75 }
76
77 want := []*Repository{{ID: Ptr(int64(1))}}
78 if !cmp.Equal(repos, want) {
79 t.Errorf("Repositories.ListByUser returned %+v, want %+v", repos, want)
80 }
81
82 const methodName = "ListByUser"
83 testBadOptions(t, methodName, func() (err error) {
84 _, _, err = client.Repositories.ListByUser(ctx, "\n", &RepositoryListByUserOptions{})
85 return err
86 })
87
88 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
89 got, resp, err := client.Repositories.ListByUser(ctx, "u", nil)
90 if got != nil {
91 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
92 }
93 return resp, err
94 })
95}
96
97func TestRepositoriesService_ListByUser_type(t *testing.T) {
98 t.Parallel()

Callers

nothing calls this directly

Calls 8

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