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

Function TestGitService_ListMatchingRefs_singleRef

github/git_refs_test.go:110–163  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

108}
109
110func TestGitService_ListMatchingRefs_singleRef(t *testing.T) {
111 t.Parallel()
112 client, mux, _ := setup(t)
113
114 mux.HandleFunc("/repos/o/r/git/matching-refs/heads/b", func(w http.ResponseWriter, r *http.Request) {
115 testMethod(t, r, "GET")
116 fmt.Fprint(w, `
117 [
118 {
119 "ref": "refs/heads/b",
120 "url": "https://api.github.com/repos/o/r/git/refs/heads/b",
121 "object": {
122 "type": "commit",
123 "sha": "aa218f56b14c9653891f9e74264a383fa43fefbd",
124 "url": "https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"
125 }
126 }
127 ]`)
128 })
129
130 ctx := t.Context()
131 refs, _, err := client.Git.ListMatchingRefs(ctx, "o", "r", "heads/b")
132 if err != nil {
133 t.Fatalf("Git.ListMatchingRefs returned error: %v", err)
134 }
135
136 ref := refs[0]
137 want := &Reference{
138 Ref: Ptr("refs/heads/b"),
139 URL: Ptr("https://api.github.com/repos/o/r/git/refs/heads/b"),
140 Object: &GitObject{
141 Type: Ptr("commit"),
142 SHA: Ptr("aa218f56b14c9653891f9e74264a383fa43fefbd"),
143 URL: Ptr("https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"),
144 },
145 }
146 if !cmp.Equal(ref, want) {
147 t.Errorf("Git.ListMatchingRefs returned %+v, want %+v", ref, want)
148 }
149
150 const methodName = "ListMatchingRefs"
151 testBadOptions(t, methodName, func() (err error) {
152 _, _, err = client.Git.ListMatchingRefs(ctx, "\n", "\n", "")
153 return err
154 })
155
156 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
157 got, resp, err := client.Git.ListMatchingRefs(ctx, "o", "r", "")
158 if got != nil {
159 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
160 }
161 return resp, err
162 })
163}
164
165func TestGitService_ListMatchingRefs_multipleRefs(t *testing.T) {
166 t.Parallel()

Callers

nothing calls this directly

Calls 7

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