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

Function TestGitService_GetRef_pathEscape

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

Source from the content-addressed store, hash-verified

529}
530
531func TestGitService_GetRef_pathEscape(t *testing.T) {
532 t.Parallel()
533 client, mux, _ := setup(t)
534
535 mux.HandleFunc("/repos/o/r/git/ref/heads/b", func(w http.ResponseWriter, r *http.Request) {
536 testMethod(t, r, "GET")
537 if strings.Contains(r.URL.RawPath, "%2F") {
538 t.Errorf("RawPath still contains escaped / as %%2F: %v", r.URL.RawPath)
539 }
540 fmt.Fprint(w, `
541 {
542 "ref": "refs/heads/b",
543 "url": "https://api.github.com/repos/o/r/git/refs/heads/b",
544 "object": {
545 "type": "commit",
546 "sha": "aa218f56b14c9653891f9e74264a383fa43fefbd",
547 "url": "https://api.github.com/repos/o/r/git/commits/aa218f56b14c9653891f9e74264a383fa43fefbd"
548 }
549 }`)
550 })
551
552 ctx := t.Context()
553 _, _, err := client.Git.GetRef(ctx, "o", "r", "refs/heads/b")
554 if err != nil {
555 t.Fatalf("Git.GetRef returned error: %v", err)
556 }
557
558 const methodName = "GetRef"
559 testBadOptions(t, methodName, func() (err error) {
560 _, _, err = client.Git.GetRef(ctx, "\n", "\n", "\n")
561 return err
562 })
563
564 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
565 got, resp, err := client.Git.GetRef(ctx, "o", "r", "refs/heads/b")
566 if got != nil {
567 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
568 }
569 return resp, err
570 })
571}
572
573func TestGitService_UpdateRef_pathEscape(t *testing.T) {
574 t.Parallel()

Callers

nothing calls this directly

Calls 5

testMethodFunction · 0.85
testBadOptionsFunction · 0.85
setupFunction · 0.70
GetRefMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…