use constants from http pkg

This commit is contained in:
Kirill Zhuravlev 2023-02-15 18:22:36 +01:00 committed by Avelino
parent c910a811d7
commit 257a031f08
No known key found for this signature in database
GPG Key ID: B345B4D52E98180A

View File

@ -111,19 +111,17 @@ func createIssue(t *testing.T, staleRepos []string, client *http.Client) {
buf := bytes.NewBuffer(nil) buf := bytes.NewBuffer(nil)
requireNoErr(t, json.NewEncoder(buf).Encode(newIssue), "failed to encode json req") requireNoErr(t, json.NewEncoder(buf).Encode(newIssue), "failed to encode json req")
req, err := http.NewRequest("POST", githubPOSTISSUES, buf) req, err := http.NewRequest(http.MethodPost, githubPOSTISSUES, buf)
requireNoErr(t, err, "failed to create request") requireNoErr(t, err, "failed to create request")
_, roundTripErr := client.Do(req) _, roundTripErr := client.Do(req)
requireNoErr(t, roundTripErr, "failed to send request") requireNoErr(t, roundTripErr, "failed to send request")
} }
// FIXME: remove pointer from map
func getAllFlaggedRepositories(t *testing.T, client *http.Client) map[string]bool { func getAllFlaggedRepositories(t *testing.T, client *http.Client) map[string]bool {
t.Helper() t.Helper()
// FIXME: replace to http.MethodGet req, err := http.NewRequest(http.MethodGet, awesomeGoGETISSUES, nil)
req, err := http.NewRequest("GET", awesomeGoGETISSUES, nil)
requireNoErr(t, err, "failed to create request") requireNoErr(t, err, "failed to create request")
res, err := client.Do(req) res, err := client.Do(req)
@ -156,7 +154,7 @@ func checkRepoAvailability(toRun bool, href string, client *http.Client) ([]stri
ownerRepo := strings.ReplaceAll(href, "https://github.com", "") ownerRepo := strings.ReplaceAll(href, "https://github.com", "")
apiCall := fmt.Sprintf(githubGETREPO, ownerRepo) apiCall := fmt.Sprintf(githubGETREPO, ownerRepo)
req, err := http.NewRequest("GET", apiCall, nil) req, err := http.NewRequest(http.MethodGet, apiCall, nil)
if err != nil { if err != nil {
log.Printf("Failed at repository %s\n", href) log.Printf("Failed at repository %s\n", href)
return nil, false return nil, false
@ -216,7 +214,7 @@ func checkRepoCommitActivity(toRun bool, href string, client *http.Client) ([]st
ownerRepo := strings.ReplaceAll(href, "https://github.com", "") ownerRepo := strings.ReplaceAll(href, "https://github.com", "")
apiCall := fmt.Sprintf(githubGETCOMMITS, ownerRepo) apiCall := fmt.Sprintf(githubGETCOMMITS, ownerRepo)
req, err := http.NewRequest("GET", apiCall, nil) req, err := http.NewRequest(http.MethodGet, apiCall, nil)
if err != nil { if err != nil {
log.Printf("Failed at repository %s\n", href) log.Printf("Failed at repository %s\n", href)
return nil, false return nil, false