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

Function TestGistsService_Edit

github/gists_test.go:538–607  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

536}
537
538func TestGistsService_Edit(t *testing.T) {
539 t.Parallel()
540 client, mux, _ := setup(t)
541
542 input := &Gist{
543 Description: Ptr("New description"),
544 Files: map[GistFilename]GistFile{
545 "new.txt": {Content: Ptr("new file content")},
546 },
547 }
548
549 mux.HandleFunc("/gists/1", func(w http.ResponseWriter, r *http.Request) {
550 var v *Gist
551 assertNilError(t, json.NewDecoder(r.Body).Decode(&v))
552
553 testMethod(t, r, "PATCH")
554 if !cmp.Equal(v, input) {
555 t.Errorf("Request body = %+v, want %+v", v, input)
556 }
557
558 fmt.Fprint(w,
559 `
560 {
561 "id": "1",
562 "description": "new description",
563 "public": false,
564 "files": {
565 "test.txt": {
566 "filename": "test.txt"
567 },
568 "new.txt": {
569 "filename": "new.txt"
570 }
571 }
572 }`)
573 })
574
575 ctx := t.Context()
576 gist, _, err := client.Gists.Edit(ctx, "1", input)
577 if err != nil {
578 t.Errorf("Gists.Edit returned error: %v", err)
579 }
580
581 want := &Gist{
582 ID: Ptr("1"),
583 Description: Ptr("new description"),
584 Public: Ptr(false),
585 Files: map[GistFilename]GistFile{
586 "test.txt": {Filename: Ptr("test.txt")},
587 "new.txt": {Filename: Ptr("new.txt")},
588 },
589 }
590 if !cmp.Equal(gist, want) {
591 t.Errorf("Gists.Edit returned %+v, want %+v", gist, want)
592 }
593
594 const methodName = "Edit"
595 testBadOptions(t, methodName, func() (err error) {

Callers

nothing calls this directly

Calls 8

testMethodFunction · 0.85
testBadOptionsFunction · 0.85
EqualMethod · 0.80
setupFunction · 0.70
PtrFunction · 0.70
assertNilErrorFunction · 0.70
EditMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…