From 073251ec17681283b8cbe33c4788994f98beee37 Mon Sep 17 00:00:00 2001 From: CHIKAMATSU Naohiro Date: Thu, 23 Feb 2023 23:46:41 +0900 Subject: [PATCH] Fix: string /repos/owner/repo/pulls has 3 occurrences, make it a constant (goconst) --- infrastructure/github/github_test.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/infrastructure/github/github_test.go b/infrastructure/github/github_test.go index b77c0a1..1c60ba5 100644 --- a/infrastructure/github/github_test.go +++ b/infrastructure/github/github_test.go @@ -190,12 +190,14 @@ func TestListRepositories(t *testing.T) { func TestClient_ListPullRequests(t *testing.T) { t.Parallel() + const apiURL = "/repos/owner/repo/pulls" + t.Run("Get PR list", func(t *testing.T) { t.Parallel() now := time.Date(2023, 2, 24, 12, 34, 56, 0, time.UTC) testServer := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { - wantURL := "/repos/owner/repo/pulls" + wantURL := apiURL if wantURL != req.URL.Path { t.Errorf("mismatch want=%v, got=%s", wantURL, req.URL.Path) } @@ -318,7 +320,7 @@ func TestClient_ListPullRequests(t *testing.T) { ctx := context.Background() testServer := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { - wantURL := "/repos/owner/repo/pulls" + wantURL := apiURL if wantURL != req.URL.Path { t.Errorf("mismatch want=%v, got=%s", wantURL, req.URL.Path) } @@ -369,7 +371,7 @@ func TestClient_ListPullRequests(t *testing.T) { ctx := context.Background() testServer := httptest.NewServer(http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) { - wantURL := "/repos/owner/repo/pulls" + wantURL := apiURL if wantURL != req.URL.Path { t.Errorf("mismatch want=%v, got=%s", wantURL, req.URL.Path) }