(t *testing.T)
| 571 | } |
| 572 | |
| 573 | func TestGitService_UpdateRef_pathEscape(t *testing.T) { |
| 574 | t.Parallel() |
| 575 | client, mux, _ := setup(t) |
| 576 | |
| 577 | args := UpdateRef{ |
| 578 | SHA: "aa218f56b14c9653891f9e74264a383fa43fefbd", |
| 579 | Force: Ptr(true), |
| 580 | } |
| 581 | |
| 582 | mux.HandleFunc("/repos/o/r/git/refs/heads/b#1", func(w http.ResponseWriter, r *http.Request) { |
| 583 | testMethod(t, r, "PATCH") |
| 584 | testJSONBody(t, r, args) |
| 585 | fmt.Fprint(w, ` |
| 586 | { |
| 587 | "ref": "refs/heads/b#1", |
| 588 | "url": "https://api.github.com/repos/o/r/git/refs/heads/b%231", |
| 589 | "object": { |
| 590 | "type": "commit", |
| 591 | "sha": "aa218f56b14c9653891f9e74264a383fa43fefbd", |
| 592 | "url": "https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd" |
| 593 | } |
| 594 | }`) |
| 595 | }) |
| 596 | |
| 597 | ctx := t.Context() |
| 598 | ref, _, err := client.Git.UpdateRef(ctx, "o", "r", "refs/heads/b#1", UpdateRef{ |
| 599 | SHA: "aa218f56b14c9653891f9e74264a383fa43fefbd", |
| 600 | Force: Ptr(true), |
| 601 | }) |
| 602 | if err != nil { |
| 603 | t.Errorf("Git.UpdateRef returned error: %v", err) |
| 604 | } |
| 605 | |
| 606 | want := &Reference{ |
| 607 | Ref: Ptr("refs/heads/b#1"), |
| 608 | URL: Ptr("https://api.github.com/repos/o/r/git/refs/heads/b%231"), |
| 609 | Object: &GitObject{ |
| 610 | Type: Ptr("commit"), |
| 611 | SHA: Ptr("aa218f56b14c9653891f9e74264a383fa43fefbd"), |
| 612 | URL: Ptr("https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"), |
| 613 | }, |
| 614 | } |
| 615 | if !cmp.Equal(ref, want) { |
| 616 | t.Errorf("Git.UpdateRef returned %+v, want %+v", ref, want) |
| 617 | } |
| 618 | } |
| 619 | |
| 620 | func TestReference_Marshal(t *testing.T) { |
| 621 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…