Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use http constants to replace numbers as parameters #7216

Merged
merged 1 commit into from
Feb 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions config/confighttp/compression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ func TestHTTPClientCompression(t *testing.T) {
serverURL := fmt.Sprintf("http://%s", ln.Addr().String())
reqBody := bytes.NewBuffer(testBody)

req, err := http.NewRequest("GET", serverURL, reqBody)
req, err := http.NewRequest(http.MethodGet, serverURL, reqBody)
require.NoError(t, err, "failed to create request to test handler")

client := http.Client{}
Expand Down Expand Up @@ -216,7 +216,7 @@ func TestHTTPContentDecompressionHandler(t *testing.T) {
reqBody, err := tt.reqBodyFunc()
require.NoError(t, err, "failed to generate request body: %v", err)

req, err := http.NewRequest("GET", serverURL, reqBody)
req, err := http.NewRequest(http.MethodGet, serverURL, reqBody)
require.NoError(t, err, "failed to create request to test handler")
req.Header.Set("Content-Encoding", tt.encoding)

Expand Down Expand Up @@ -245,7 +245,7 @@ func TestHTTPContentCompressionRequestWithNilBody(t *testing.T) {
}))
defer server.Close()

req, err := http.NewRequest("GET", server.URL, nil)
req, err := http.NewRequest(http.MethodGet, server.URL, nil)
require.NoError(t, err, "failed to create request to test handler")

client := http.Client{}
Expand Down
4 changes: 2 additions & 2 deletions config/confighttp/confighttp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ func TestHttpCorsWithSettings(t *testing.T) {
}

func verifyCorsResp(t *testing.T, url string, origin string, maxAge int, extraHeader bool, wantStatus int, wantAllowed bool) {
req, err := http.NewRequest("OPTIONS", url, nil)
req, err := http.NewRequest(http.MethodOptions, url, nil)
require.NoError(t, err, "Error creating trace OPTIONS request: %v", err)
req.Header.Set("Origin", origin)
if extraHeader {
Expand Down Expand Up @@ -853,7 +853,7 @@ func TestHttpHeaders(t *testing.T) {
Headers: tt.headers,
}
client, _ := setting.ToClient(componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings())
req, err := http.NewRequest("GET", setting.Endpoint, nil)
req, err := http.NewRequest(http.MethodGet, setting.Endpoint, nil)
assert.NoError(t, err)
_, err = client.Do(req)
assert.NoError(t, err)
Expand Down
2 changes: 1 addition & 1 deletion obsreport/obsreporttest/otelprometheuschecker.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (pc *prometheusChecker) getMetric(expectedName string, expectedType io_prom
}

func fetchPrometheusMetrics(handler http.Handler) (map[string]*io_prometheus_client.MetricFamily, error) {
req, err := http.NewRequest("GET", "/metrics", nil)
req, err := http.NewRequest(http.MethodGet, "/metrics", nil)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion processor/batchprocessor/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (tt *testTelemetry) assertMetrics(t *testing.T, expected expectedMetrics) {
_, _ = view.RetrieveData(v.Name)
}

req, err := http.NewRequest("GET", "/metrics", nil)
req, err := http.NewRequest(http.MethodGet, "/metrics", nil)
require.NoError(t, err)

rr := httptest.NewRecorder()
Expand Down
2 changes: 1 addition & 1 deletion service/internal/proctelemetry/process_telemetry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func setupTelemetry(t *testing.T) testTelemetry {
}

func fetchPrometheusMetrics(handler http.Handler) (map[string]*io_prometheus_client.MetricFamily, error) {
req, err := http.NewRequest("GET", "/metrics", nil)
req, err := http.NewRequest(http.MethodGet, "/metrics", nil)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion service/telemetry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ func createTestMetrics(t *testing.T, mp metric.MeterProvider) *view.View {
}

func getMetricsFromPrometheus(t *testing.T, handler http.Handler) map[string]*io_prometheus_client.MetricFamily {
req, err := http.NewRequest("GET", "/metrics", nil)
req, err := http.NewRequest(http.MethodGet, "/metrics", nil)
require.NoError(t, err)

rr := httptest.NewRecorder()
Expand Down