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

Function TestGitService_GetRef_noRefs

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

Source from the content-addressed store, hash-verified

72}
73
74func TestGitService_GetRef_noRefs(t *testing.T) {
75 t.Parallel()
76 client, mux, _ := setup(t)
77
78 mux.HandleFunc("/repos/o/r/git/refs/heads/b", func(w http.ResponseWriter, r *http.Request) {
79 testMethod(t, r, "GET")
80 w.WriteHeader(http.StatusNotFound)
81 })
82
83 ctx := t.Context()
84 ref, resp, err := client.Git.GetRef(ctx, "o", "r", "refs/heads/b")
85 if err == nil {
86 t.Error("Expected HTTP 404 response")
87 }
88 if got, want := resp.Response.StatusCode, http.StatusNotFound; got != want {
89 t.Errorf("Git.GetRef returned status %v, want %v", got, want)
90 }
91 if ref != nil {
92 t.Errorf("Git.GetRef return %+v, want nil", ref)
93 }
94
95 const methodName = "GetRef"
96 testBadOptions(t, methodName, func() (err error) {
97 _, _, err = client.Git.GetRef(ctx, "o", "r", "refs/heads/b")
98 return err
99 })
100
101 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
102 got, resp, err := client.Git.GetRef(ctx, "o", "r", "refs/heads/b")
103 if got != nil {
104 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
105 }
106 return resp, err
107 })
108}
109
110func TestGitService_ListMatchingRefs_singleRef(t *testing.T) {
111 t.Parallel()

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…