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

Function TestGitService_UpdateRef_pathEscape

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

Source from the content-addressed store, hash-verified

571}
572
573func 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
620func TestReference_Marshal(t *testing.T) {
621 t.Parallel()

Callers

nothing calls this directly

Calls 6

testMethodFunction · 0.85
testJSONBodyFunction · 0.85
UpdateRefMethod · 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…