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

Function TestRepositoriesService_UpdateComment

github/repos_comments_test.go:203–245  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

201}
202
203func TestRepositoriesService_UpdateComment(t *testing.T) {
204 t.Parallel()
205 client, mux, _ := setup(t)
206
207 input := &RepositoryComment{Body: Ptr("b")}
208
209 mux.HandleFunc("/repos/o/r/comments/1", func(w http.ResponseWriter, r *http.Request) {
210 var v *RepositoryComment
211 assertNilError(t, json.NewDecoder(r.Body).Decode(&v))
212
213 testMethod(t, r, "PATCH")
214 if !cmp.Equal(v, input) {
215 t.Errorf("Request body = %+v, want %+v", v, input)
216 }
217
218 fmt.Fprint(w, `{"id":1}`)
219 })
220
221 ctx := t.Context()
222 comment, _, err := client.Repositories.UpdateComment(ctx, "o", "r", 1, input)
223 if err != nil {
224 t.Errorf("Repositories.UpdateComment returned error: %v", err)
225 }
226
227 want := &RepositoryComment{ID: Ptr(int64(1))}
228 if !cmp.Equal(comment, want) {
229 t.Errorf("Repositories.UpdateComment returned %+v, want %+v", comment, want)
230 }
231
232 const methodName = "UpdateComment"
233 testBadOptions(t, methodName, func() (err error) {
234 _, _, err = client.Repositories.UpdateComment(ctx, "\n", "\n", -1, input)
235 return err
236 })
237
238 testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
239 got, resp, err := client.Repositories.UpdateComment(ctx, "o", "r", 1, input)
240 if got != nil {
241 t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
242 }
243 return resp, err
244 })
245}
246
247func TestRepositoriesService_UpdateComment_invalidOwner(t *testing.T) {
248 t.Parallel()

Callers

nothing calls this directly

Calls 8

testMethodFunction · 0.85
testBadOptionsFunction · 0.85
EqualMethod · 0.80
UpdateCommentMethod · 0.80
setupFunction · 0.70
PtrFunction · 0.70
assertNilErrorFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…