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

Function TestGitService_GetCommit

github/git_commits_test.go:130–163  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

128}
129
130func TestGitService_GetCommit(t *testing.T) {
131 t.Parallel()
132 client, mux, _ := setup(t)
133
134 mux.HandleFunc("/repos/o/r/git/commits/s", func(w http.ResponseWriter, r *http.Request) {
135 testMethod(t, r, "GET")
136 fmt.Fprint(w, `{"sha":"s","message":"Commit Message.","author":{"name":"n"}}`)
137 })
138
139 ctx := t.Context()
140 commit, _, err := client.Git.GetCommit(ctx, "o", "r", "s")
141 if err != nil {
142 t.Errorf("Git.GetCommit returned error: %v", err)
143 }
144
145 want := &Commit{SHA: Ptr("s"), Message: Ptr("Commit Message."), Author: &CommitAuthor{Name: Ptr("n")}}
146 if !cmp.Equal(commit, want) {
147 t.Errorf("Git.GetCommit returned %+v, want %+v", commit, want)
148 }
149
150 const methodName = "GetCommit"
151 testBadOptions(t, methodName, func() (err error) {
152 _, _, err = client.Git.GetCommit(ctx, "\n", "\n", "\n")
153 return err
154 })
155
156 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
157 got, resp, err := client.Git.GetCommit(ctx, "o", "r", "s")
158 if got != nil {
159 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
160 }
161 return resp, err
162 })
163}
164
165func TestGitService_GetCommit_invalidOwner(t *testing.T) {
166 t.Parallel()

Callers

nothing calls this directly

Calls 7

testMethodFunction · 0.85
testBadOptionsFunction · 0.85
EqualMethod · 0.80
setupFunction · 0.70
PtrFunction · 0.70
GetCommitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…