(t *testing.T)
| 261 | } |
| 262 | |
| 263 | func TestGitService_ListMatchingRefs_allRefs(t *testing.T) { |
| 264 | t.Parallel() |
| 265 | client, mux, _ := setup(t) |
| 266 | |
| 267 | mux.HandleFunc("/repos/o/r/git/matching-refs/", func(w http.ResponseWriter, r *http.Request) { |
| 268 | testMethod(t, r, "GET") |
| 269 | fmt.Fprint(w, ` |
| 270 | [ |
| 271 | { |
| 272 | "ref": "refs/heads/branchA", |
| 273 | "url": "https://api.github.com/repos/o/r/git/refs/heads/branchA", |
| 274 | "object": { |
| 275 | "type": "commit", |
| 276 | "sha": "aa218f56b14c9653891f9e74264a383fa43fefbd", |
| 277 | "url": "https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd" |
| 278 | } |
| 279 | }, |
| 280 | { |
| 281 | "ref": "refs/heads/branchB", |
| 282 | "url": "https://api.github.com/repos/o/r/git/refs/heads/branchB", |
| 283 | "object": { |
| 284 | "type": "commit", |
| 285 | "sha": "aa218f56b14c9653891f9e74264a383fa43fefbd", |
| 286 | "url": "https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd" |
| 287 | } |
| 288 | } |
| 289 | ]`) |
| 290 | }) |
| 291 | |
| 292 | ctx := t.Context() |
| 293 | refs, _, err := client.Git.ListMatchingRefs(ctx, "o", "r", "") |
| 294 | if err != nil { |
| 295 | t.Errorf("Git.ListMatchingRefs returned error: %v", err) |
| 296 | } |
| 297 | |
| 298 | want := []*Reference{ |
| 299 | { |
| 300 | Ref: Ptr("refs/heads/branchA"), |
| 301 | URL: Ptr("https://api.github.com/repos/o/r/git/refs/heads/branchA"), |
| 302 | Object: &GitObject{ |
| 303 | Type: Ptr("commit"), |
| 304 | SHA: Ptr("aa218f56b14c9653891f9e74264a383fa43fefbd"), |
| 305 | URL: Ptr("https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"), |
| 306 | }, |
| 307 | }, |
| 308 | { |
| 309 | Ref: Ptr("refs/heads/branchB"), |
| 310 | URL: Ptr("https://api.github.com/repos/o/r/git/refs/heads/branchB"), |
| 311 | Object: &GitObject{ |
| 312 | Type: Ptr("commit"), |
| 313 | SHA: Ptr("aa218f56b14c9653891f9e74264a383fa43fefbd"), |
| 314 | URL: Ptr("https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"), |
| 315 | }, |
| 316 | }, |
| 317 | } |
| 318 | if !cmp.Equal(refs, want) { |
| 319 | t.Errorf("Git.ListMatchingRefs returned %+v, want %+v", refs, want) |
| 320 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…