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

Function TestWithURLs

github/github_test.go:639–726  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

637}
638
639func TestWithURLs(t *testing.T) {
640 t.Parallel()
641 for _, tt := range []struct {
642 name string
643 baseURL *string
644 wantBaseURL *string
645 uploadURL *string
646 wantUploadURL *string
647 wantErr string
648 }{
649 {
650 name: "does_not_modify_urls_with_trailing_slash",
651 baseURL: Ptr("https://example.com/"),
652 wantBaseURL: Ptr("https://example.com/"),
653 uploadURL: Ptr("https://upload.example.com/"),
654 wantUploadURL: Ptr("https://upload.example.com/"),
655 },
656 {
657 name: "adds_trailing_slash",
658 baseURL: Ptr("https://example.com"),
659 wantBaseURL: Ptr("https://example.com/"),
660 uploadURL: Ptr("https://upload.example.com"),
661 wantUploadURL: Ptr("https://upload.example.com/"),
662 },
663 {
664 name: "skips_unset",
665 },
666 {
667 name: "error_on_empty_base_url",
668 baseURL: Ptr(""),
669 wantErr: "invalid base url: url cannot be empty",
670 },
671 {
672 name: "error_on_bad_base_url",
673 baseURL: Ptr("bogus\nbase\nURL"),
674 wantErr: "invalid base url: invalid url",
675 },
676 {
677 name: "error_on_empty_upload_url",
678 baseURL: Ptr("https://example.com/"),
679 uploadURL: Ptr(""),
680 wantErr: "invalid upload url: url cannot be empty",
681 },
682 {
683 name: "error_on_bad_upload_url",
684 baseURL: Ptr("https://example.com/"),
685 uploadURL: Ptr("bogus\nupload\nURL"),
686 wantErr: "invalid upload url: invalid url",
687 },
688 } {
689 t.Run(tt.name, func(t *testing.T) {
690 t.Parallel()
691
692 opts := clientOptions{}
693 err := WithURLs(tt.baseURL, tt.uploadURL)(&opts)
694 if err != nil {
695 if tt.wantErr == "" {
696 t.Fatalf("unexpected error: %v", err)

Callers

nothing calls this directly

Calls 5

WithURLsFunction · 0.85
PtrFunction · 0.70
RunMethod · 0.45
ErrorMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…