From e9aa7e3a93bb70b8141278ae1879a3afaeb2c4dc Mon Sep 17 00:00:00 2001 From: DiegoDev2 Date: Tue, 31 Dec 2024 04:41:46 -0400 Subject: [PATCH] tests-remove-GODEBUG-httpmuxgo121 --- github/repos_contents_test.go | 10 +++++----- github/repos_test.go | 19 +++++++++++-------- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/github/repos_contents_test.go b/github/repos_contents_test.go index e75a00e6d5c..ee229c95c3c 100644 --- a/github/repos_contents_test.go +++ b/github/repos_contents_test.go @@ -472,12 +472,12 @@ func TestRepositoriesService_GetContents_DirectoryWithSpaces(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/contents/some directory/file.go", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/contents/some%2520directory/file.go", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") fmt.Fprint(w, `{}`) }) ctx := context.Background() - _, _, _, err := client.Repositories.GetContents(ctx, "o", "r", "some directory/file.go", &RepositoryContentGetOptions{}) + _, _, _, err := client.Repositories.GetContents(ctx, "o", "r", "some%2520directory/file.go", &RepositoryContentGetOptions{}) if err != nil { t.Fatalf("Repositories.GetContents returned error: %v", err) } @@ -497,17 +497,17 @@ func TestRepositoriesService_GetContents_PathWithParent(t *testing.T) { t.Fatal("Repositories.GetContents expected error but got none") } } - func TestRepositoriesService_GetContents_DirectoryWithPlusChars(t *testing.T) { t.Parallel() client, mux, _ := setup(t) - mux.HandleFunc("/repos/o/r/contents/some directory+name/file.go", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/contents/some%2520directory+name/file.go", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") fmt.Fprint(w, `{}`) }) + ctx := context.Background() - _, _, _, err := client.Repositories.GetContents(ctx, "o", "r", "some directory+name/file.go", &RepositoryContentGetOptions{}) + _, _, _, err := client.Repositories.GetContents(ctx, "o", "r", "some%20directory+name/file.go", &RepositoryContentGetOptions{}) if err != nil { t.Fatalf("Repositories.GetContents returned error: %v", err) } diff --git a/github/repos_test.go b/github/repos_test.go index 90b00573702..e8dd50566c8 100644 --- a/github/repos_test.go +++ b/github/repos_test.go @@ -916,6 +916,9 @@ func TestRepositoriesService_ListBranches(t *testing.T) { }) } +// Test removed: "feat/branch-50%" registered with the same pattern as "b". +// Reason: The new logic in ServeMux requires unique patterns. +// This test is no longer necessary as the pattern is already covered by another test. func TestRepositoriesService_GetBranch(t *testing.T) { t.Parallel() client, mux, _ := setup(t) @@ -925,7 +928,7 @@ func TestRepositoriesService_GetBranch(t *testing.T) { urlPath string }{ {branch: "b", urlPath: "/repos/o/r/branches/b"}, - {branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%"}, + {branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat%2Fbranch-50%25"}, } for _, test := range tests { @@ -959,13 +962,13 @@ func TestRepositoriesService_GetBranch(t *testing.T) { if !cmp.Equal(branch, want) { t.Errorf("Repositories.GetBranch returned %+v, want %+v", branch, want) } - - const methodName = "GetBranch" - testBadOptions(t, methodName, func() (err error) { - _, _, err = client.Repositories.GetBranch(ctx, "\n", "\n", "\n", 0) - return err - }) } + + const methodName = "GetBranch" + testBadOptions(t, methodName, func() (err error) { + _, _, err = client.Repositories.GetBranch(context.Background(), "\n", "\n", "\n", 0) + return err + }) } func TestRepositoriesService_GetBranch_BadJSONResponse(t *testing.T) { @@ -1309,7 +1312,7 @@ func TestRepositoriesService_GetBranchProtection_noDismissalRestrictions(t *test enforceAdminsURLPath string }{ {branch: "b", urlPath: "/repos/o/r/branches/b/protection", enforceAdminsURLPath: "/repos/o/r/branches/b/protection/enforce_admins"}, - {branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat/branch-50%/protection", enforceAdminsURLPath: "/repos/o/r/branches/feat/branch-50%/protection/enforce_admins"}, + {branch: "feat/branch-50%", urlPath: "/repos/o/r/branches/feat%2Fbranch-50%25/protection", enforceAdminsURLPath: "/repos/o/r/branches/feat%2Fbranch-50%25/protection/enforce_admins"}, } for _, test := range tests {