(t *testing.T)
| 660 | } |
| 661 | |
| 662 | func TestRepositoriesService_GetContents_File(t *testing.T) { |
| 663 | t.Parallel() |
| 664 | client, mux, _ := setup(t) |
| 665 | |
| 666 | mux.HandleFunc("/repos/o/r/contents/p", func(w http.ResponseWriter, r *http.Request) { |
| 667 | testMethod(t, r, "GET") |
| 668 | fmt.Fprint(w, `{ |
| 669 | "type": "file", |
| 670 | "encoding": "base64", |
| 671 | "size": 20678, |
| 672 | "name": "LICENSE", |
| 673 | "path": "LICENSE" |
| 674 | }`) |
| 675 | }) |
| 676 | ctx := t.Context() |
| 677 | fileContents, _, _, err := client.Repositories.GetContents(ctx, "o", "r", "p", &RepositoryContentGetOptions{}) |
| 678 | if err != nil { |
| 679 | t.Errorf("Repositories.GetContents returned error: %v", err) |
| 680 | } |
| 681 | want := &RepositoryContent{Type: Ptr("file"), Name: Ptr("LICENSE"), Size: Ptr(20678), Encoding: Ptr("base64"), Path: Ptr("LICENSE")} |
| 682 | if !cmp.Equal(fileContents, want) { |
| 683 | t.Errorf("Repositories.GetContents returned %+v, want %+v", fileContents, want) |
| 684 | } |
| 685 | |
| 686 | const methodName = "GetContents" |
| 687 | testBadOptions(t, methodName, func() (err error) { |
| 688 | _, _, _, err = client.Repositories.GetContents(ctx, "\n", "\n", "\n", &RepositoryContentGetOptions{}) |
| 689 | return err |
| 690 | }) |
| 691 | |
| 692 | testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) { |
| 693 | got, _, resp, err := client.Repositories.GetContents(ctx, "o", "r", "p", &RepositoryContentGetOptions{}) |
| 694 | if got != nil { |
| 695 | t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got) |
| 696 | } |
| 697 | return resp, err |
| 698 | }) |
| 699 | } |
| 700 | |
| 701 | func TestRepositoriesService_GetContents_FilenameNeedsEscape(t *testing.T) { |
| 702 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…