chore(linters): Fix findings found by `testifylint`: `go-require` for handlers for `plugins/inputs/[n-z]` (#16098)
This commit is contained in:
parent
dd0d92085f
commit
6045e13616
|
|
@ -71,11 +71,17 @@ func TestMetricsCorrect(t *testing.T) {
|
||||||
var acc testutil.Accumulator
|
var acc testutil.Accumulator
|
||||||
|
|
||||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
require.Equal(t, "/varz", r.URL.Path, "Cannot handle request")
|
if r.URL.Path != "/varz" {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Errorf("Cannot handle request, expected: %q, actual: %q", "/varz", r.URL.Path)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
rsp := sampleVarz
|
if _, err := fmt.Fprintln(w, sampleVarz); err != nil {
|
||||||
_, err := fmt.Fprintln(w, rsp)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
require.NoError(t, err)
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer srv.Close()
|
defer srv.Close()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,9 +16,12 @@ import (
|
||||||
|
|
||||||
func TestGather(t *testing.T) {
|
func TestGather(t *testing.T) {
|
||||||
h := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
h := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
|
if _, err := w.Write([]byte("data")); err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
_, err := w.Write([]byte("data"))
|
|
||||||
require.NoError(t, err)
|
|
||||||
})
|
})
|
||||||
c, destroy := fakeHTTPClient(h)
|
c, destroy := fakeHTTPClient(h)
|
||||||
defer destroy()
|
defer destroy()
|
||||||
|
|
@ -402,11 +405,13 @@ func TestSendRequest(t *testing.T) {
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
t.Run(test.name, func(t *testing.T) {
|
t.Run(test.name, func(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
h := http.HandlerFunc(func(
|
h := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
w http.ResponseWriter, _ *http.Request) {
|
|
||||||
w.WriteHeader(test.statusCode)
|
w.WriteHeader(test.statusCode)
|
||||||
_, err := w.Write([]byte("data"))
|
if _, err := w.Write([]byte("data")); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
})
|
})
|
||||||
c, destroy := fakeHTTPClient(h)
|
c, destroy := fakeHTTPClient(h)
|
||||||
defer destroy()
|
defer destroy()
|
||||||
|
|
|
||||||
|
|
@ -46,11 +46,16 @@ func TestNginxGeneratesMetrics(t *testing.T) {
|
||||||
} else if r.URL.Path == "/tengine_status" {
|
} else if r.URL.Path == "/tengine_status" {
|
||||||
rsp = tengineSampleResponse
|
rsp = tengineSampleResponse
|
||||||
} else {
|
} else {
|
||||||
require.Fail(t, "Cannot handle request")
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Errorf("Cannot handle request, unknown path")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := fmt.Fprintln(w, rsp)
|
if _, err := fmt.Fprintln(w, rsp); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -246,20 +246,22 @@ const sampleStatusResponse = `
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
|
|
||||||
func TestNginxPlusGeneratesMetrics(t *testing.T) {
|
func TestNginxPlusGeneratesMetrics(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
var rsp string
|
if r.URL.Path != "/status" {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Errorf("Cannot handle request, expected: %q, actual: %q", "/status", r.URL.Path)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
require.Equal(t, "/status", r.URL.Path, "Cannot handle request")
|
|
||||||
|
|
||||||
rsp = sampleStatusResponse
|
|
||||||
w.Header()["Content-Type"] = []string{"application/json"}
|
w.Header()["Content-Type"] = []string{"application/json"}
|
||||||
|
if _, err := fmt.Fprintln(w, sampleStatusResponse); err != nil {
|
||||||
_, err := fmt.Fprintln(w, rsp)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
require.NoError(t, err)
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1496,8 +1496,11 @@ func TestServerError(t *testing.T) {
|
||||||
func TestMalformedJSON(t *testing.T) {
|
func TestMalformedJSON(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||||
_, err := fmt.Fprintln(w, "this is not JSON")
|
if _, err := fmt.Fprintln(w, "this is not JSON"); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
@ -1554,11 +1557,19 @@ func prepareAddr(t *testing.T, ts *httptest.Server) (*url.URL, string, string) {
|
||||||
|
|
||||||
func prepareEndpoint(t *testing.T, path, payload string) (*httptest.Server, *NginxPlusAPI) {
|
func prepareEndpoint(t *testing.T, path, payload string) (*httptest.Server, *NginxPlusAPI) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
require.Equal(t, r.URL.Path, fmt.Sprintf("/api/%d/%s", defaultAPIVersion, path), "unknown request path")
|
fullPath := fmt.Sprintf("/api/%d/%s", defaultAPIVersion, path)
|
||||||
|
if r.URL.Path != fullPath {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Errorf("Unknown request path, expected: %q, actual: %q", fullPath, r.URL.Path)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
w.Header()["Content-Type"] = []string{"application/json"}
|
w.Header()["Content-Type"] = []string{"application/json"}
|
||||||
_, err := fmt.Fprintln(w, payload)
|
if _, err := fmt.Fprintln(w, payload); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
|
|
||||||
n := &NginxPlusAPI{
|
n := &NginxPlusAPI{
|
||||||
|
|
|
||||||
|
|
@ -160,20 +160,22 @@ const sampleStatusResponse = `
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
|
|
||||||
func TestNginxPlusGeneratesMetrics(t *testing.T) {
|
func TestNginxPlusGeneratesMetrics(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
var rsp string
|
if r.URL.Path != "/status" {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Errorf("Cannot handle request, expected: %q, actual: %q", "/status", r.URL.Path)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
require.Equal(t, "/status", r.URL.Path, "Cannot handle request")
|
|
||||||
|
|
||||||
rsp = sampleStatusResponse
|
|
||||||
w.Header()["Content-Type"] = []string{"application/json"}
|
w.Header()["Content-Type"] = []string{"application/json"}
|
||||||
|
if _, err := fmt.Fprintln(w, sampleStatusResponse); err != nil {
|
||||||
_, err := fmt.Fprintln(w, rsp)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
require.NoError(t, err)
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,20 +39,22 @@ const sampleStatusResponse = `
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
|
|
||||||
func TestNginxUpstreamCheckData(test *testing.T) {
|
func TestNginxUpstreamCheckData(test *testing.T) {
|
||||||
testServer := httptest.NewServer(http.HandlerFunc(func(responseWriter http.ResponseWriter, request *http.Request) {
|
testServer := httptest.NewServer(http.HandlerFunc(func(responseWriter http.ResponseWriter, request *http.Request) {
|
||||||
var response string
|
if request.URL.Path != "/status" {
|
||||||
|
responseWriter.WriteHeader(http.StatusInternalServerError)
|
||||||
|
test.Errorf("Cannot handle request, expected: %q, actual: %q", "/status", request.URL.Path)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
require.Equal(test, "/status", request.URL.Path, "Cannot handle request")
|
|
||||||
|
|
||||||
response = sampleStatusResponse
|
|
||||||
responseWriter.Header()["Content-Type"] = []string{"application/json"}
|
responseWriter.Header()["Content-Type"] = []string{"application/json"}
|
||||||
|
if _, err := fmt.Fprintln(responseWriter, sampleStatusResponse); err != nil {
|
||||||
_, err := fmt.Fprintln(responseWriter, response)
|
responseWriter.WriteHeader(http.StatusInternalServerError)
|
||||||
require.NoError(test, err)
|
test.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer testServer.Close()
|
defer testServer.Close()
|
||||||
|
|
||||||
|
|
@ -101,20 +103,39 @@ func TestNginxUpstreamCheckData(test *testing.T) {
|
||||||
|
|
||||||
func TestNginxUpstreamCheckRequest(test *testing.T) {
|
func TestNginxUpstreamCheckRequest(test *testing.T) {
|
||||||
testServer := httptest.NewServer(http.HandlerFunc(func(responseWriter http.ResponseWriter, request *http.Request) {
|
testServer := httptest.NewServer(http.HandlerFunc(func(responseWriter http.ResponseWriter, request *http.Request) {
|
||||||
var response string
|
if request.URL.Path != "/status" {
|
||||||
|
responseWriter.WriteHeader(http.StatusInternalServerError)
|
||||||
|
test.Errorf("Cannot handle request, expected: %q, actual: %q", "/status", request.URL.Path)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
require.Equal(test, "/status", request.URL.Path, "Cannot handle request")
|
|
||||||
|
|
||||||
response = sampleStatusResponse
|
|
||||||
responseWriter.Header()["Content-Type"] = []string{"application/json"}
|
responseWriter.Header()["Content-Type"] = []string{"application/json"}
|
||||||
|
if _, err := fmt.Fprintln(responseWriter, sampleStatusResponse); err != nil {
|
||||||
|
responseWriter.WriteHeader(http.StatusInternalServerError)
|
||||||
|
test.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
_, err := fmt.Fprintln(responseWriter, response)
|
if request.Method != "POST" {
|
||||||
require.NoError(test, err)
|
responseWriter.WriteHeader(http.StatusInternalServerError)
|
||||||
|
test.Errorf("Not equal, expected: %q, actual: %q", "POST", request.Method)
|
||||||
require.Equal(test, "POST", request.Method)
|
return
|
||||||
require.Equal(test, "test-value", request.Header.Get("X-Test"))
|
}
|
||||||
require.Equal(test, "Basic dXNlcjpwYXNzd29yZA==", request.Header.Get("Authorization"))
|
if request.Header.Get("X-Test") != "test-value" {
|
||||||
require.Equal(test, "status.local", request.Host)
|
responseWriter.WriteHeader(http.StatusInternalServerError)
|
||||||
|
test.Errorf("Not equal, expected: %q, actual: %q", "test-value", request.Header.Get("X-Test"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if request.Header.Get("Authorization") != "Basic dXNlcjpwYXNzd29yZA==" {
|
||||||
|
responseWriter.WriteHeader(http.StatusInternalServerError)
|
||||||
|
test.Errorf("Not equal, expected: %q, actual: %q", "Basic dXNlcjpwYXNzd29yZA==", request.Header.Get("Authorization"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if request.Host != "status.local" {
|
||||||
|
responseWriter.WriteHeader(http.StatusInternalServerError)
|
||||||
|
test.Errorf("Not equal, expected: %q, actual: %q", "status.local", request.Host)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer testServer.Close()
|
defer testServer.Close()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -197,20 +197,22 @@ const sampleStatusResponse = `
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}`
|
||||||
`
|
|
||||||
|
|
||||||
func TestNginxPlusGeneratesMetrics(t *testing.T) {
|
func TestNginxPlusGeneratesMetrics(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
var rsp string
|
if r.URL.Path != "/status" {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Errorf("Cannot handle request, expected: %q, actual: %q", "/status", r.URL.Path)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
require.Equal(t, "/status", r.URL.Path, "Cannot handle request")
|
|
||||||
|
|
||||||
rsp = sampleStatusResponse
|
|
||||||
w.Header()["Content-Type"] = []string{"application/json"}
|
w.Header()["Content-Type"] = []string{"application/json"}
|
||||||
|
if _, err := fmt.Fprintln(w, sampleStatusResponse); err != nil {
|
||||||
_, err := fmt.Fprintln(w, rsp)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
require.NoError(t, err)
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -80,11 +80,19 @@ func TestNomadStats(t *testing.T) {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.RequestURI == "/v1/metrics" {
|
if r.RequestURI == "/v1/metrics" {
|
||||||
w.WriteHeader(http.StatusOK)
|
|
||||||
responseKeyMetrics, err := os.ReadFile("testdata/response_key_metrics.json")
|
responseKeyMetrics, err := os.ReadFile("testdata/response_key_metrics.json")
|
||||||
require.NoError(t, err)
|
if err != nil {
|
||||||
_, err = fmt.Fprintln(w, string(responseKeyMetrics))
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
require.NoError(t, err)
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err = fmt.Fprintln(w, string(responseKeyMetrics)); err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,12 @@ import (
|
||||||
|
|
||||||
func TestNSQStatsV1(t *testing.T) {
|
func TestNSQStatsV1(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
|
if _, err := fmt.Fprintln(w, responseV1); err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
_, err := fmt.Fprintln(w, responseV1)
|
|
||||||
require.NoError(t, err)
|
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
@ -271,9 +274,12 @@ var responseV1 = `
|
||||||
// TestNSQStatsPreV1 is for backwards compatibility with nsq versions < 1.0
|
// TestNSQStatsPreV1 is for backwards compatibility with nsq versions < 1.0
|
||||||
func TestNSQStatsPreV1(t *testing.T) {
|
func TestNSQStatsPreV1(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
|
if _, err := fmt.Fprintln(w, responsePreV1); err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
_, err := fmt.Fprintln(w, responsePreV1)
|
|
||||||
require.NoError(t, err)
|
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -100,8 +100,10 @@ func TestCases(t *testing.T) {
|
||||||
key := strings.TrimPrefix(r.URL.Path, "/data/2.5/")
|
key := strings.TrimPrefix(r.URL.Path, "/data/2.5/")
|
||||||
if resp, found := input[key]; found {
|
if resp, found := input[key]; found {
|
||||||
w.Header()["Content-Type"] = []string{"application/json"}
|
w.Header()["Content-Type"] = []string{"application/json"}
|
||||||
_, err := w.Write(resp)
|
if _, err := w.Write(resp); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -115,8 +117,10 @@ func TestCases(t *testing.T) {
|
||||||
key += "_" + ids[0]
|
key += "_" + ids[0]
|
||||||
if resp, found := input[key]; found {
|
if resp, found := input[key]; found {
|
||||||
w.Header()["Content-Type"] = []string{"application/json"}
|
w.Header()["Content-Type"] = []string{"application/json"}
|
||||||
_, err := w.Write(resp)
|
if _, err := w.Write(resp); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,6 @@ import (
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/stretchr/testify/require"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const requestID uint16 = 1
|
const requestID uint16 = 1
|
||||||
|
|
@ -238,13 +236,13 @@ func TestChildServeCleansUp(t *testing.T) {
|
||||||
copy(input, tt.input)
|
copy(input, tt.input)
|
||||||
rc := nopWriteCloser{bytes.NewBuffer(input)}
|
rc := nopWriteCloser{bytes.NewBuffer(input)}
|
||||||
done := make(chan bool)
|
done := make(chan bool)
|
||||||
c := newChild(rc, http.HandlerFunc(func(
|
c := newChild(rc, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
_ http.ResponseWriter,
|
|
||||||
r *http.Request,
|
|
||||||
) {
|
|
||||||
// block on reading body of request
|
// block on reading body of request
|
||||||
_, err := io.Copy(io.Discard, r.Body)
|
_, err := io.Copy(io.Discard, r.Body)
|
||||||
require.ErrorIs(t, err, tt.err)
|
if !errors.Is(err, tt.err) {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Errorf("Not equal, expected: %v, actual: %v", tt.err, err)
|
||||||
|
}
|
||||||
// not reached if body of request isn't closed
|
// not reached if body of request isn't closed
|
||||||
done <- true
|
done <- true
|
||||||
}))
|
}))
|
||||||
|
|
|
||||||
|
|
@ -39,11 +39,19 @@ func (s statServer) ServeHTTP(w http.ResponseWriter, _ *http.Request) {
|
||||||
|
|
||||||
func TestPhpFpmGeneratesMetrics_From_Http(t *testing.T) {
|
func TestPhpFpmGeneratesMetrics_From_Http(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
require.Equal(t, "ok", r.URL.Query().Get("test"))
|
if r.URL.Query().Get("test") != "ok" {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Errorf("Not equal, expected: %q, actual: %q", "ok", r.URL.Query().Get("test"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "text/plain")
|
w.Header().Set("Content-Type", "text/plain")
|
||||||
w.Header().Set("Content-Length", strconv.Itoa(len(outputSample)))
|
w.Header().Set("Content-Length", strconv.Itoa(len(outputSample)))
|
||||||
_, err := fmt.Fprint(w, outputSample)
|
if _, err := fmt.Fprint(w, outputSample); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
@ -85,8 +93,11 @@ func TestPhpFpmGeneratesJSONMetrics_From_Http(t *testing.T) {
|
||||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
w.Header().Set("Content-Type", "text/json")
|
w.Header().Set("Content-Type", "text/json")
|
||||||
w.Header().Set("Content-Length", strconv.Itoa(len(outputSampleJSON)))
|
w.Header().Set("Content-Length", strconv.Itoa(len(outputSampleJSON)))
|
||||||
_, err := fmt.Fprint(w, string(outputSampleJSON))
|
if _, err := fmt.Fprint(w, string(outputSampleJSON)); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,11 @@ go_goroutines 15 1490802350000`
|
||||||
|
|
||||||
func TestPrometheusGeneratesMetrics(t *testing.T) {
|
func TestPrometheusGeneratesMetrics(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
_, err := fmt.Fprintln(w, sampleTextFormat)
|
if _, err := fmt.Fprintln(w, sampleTextFormat); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
@ -83,14 +86,23 @@ func TestPrometheusCustomHeader(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
switch r.Header.Get("accept") {
|
switch r.Header.Get("accept") {
|
||||||
case "application/vnd.google.protobuf;proto=io.prometheus.client.MetricFamily;encoding=delimited;q=0.7,text/plain;version=0.0.4;q=0.3":
|
case "application/vnd.google.protobuf;proto=io.prometheus.client.MetricFamily;encoding=delimited;q=0.7,text/plain;version=0.0.4;q=0.3":
|
||||||
_, err := fmt.Fprintln(w, "proto 15 1490802540000")
|
if _, err := fmt.Fprintln(w, "proto 15 1490802540000"); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
case "text/plain":
|
case "text/plain":
|
||||||
_, err := fmt.Fprintln(w, "plain 42 1490802380000")
|
if _, err := fmt.Fprintln(w, "plain 42 1490802380000"); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
_, err := fmt.Fprintln(w, "other 44 1490802420000")
|
if _, err := fmt.Fprintln(w, "other 44 1490802420000"); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
@ -139,8 +151,11 @@ func TestPrometheusCustomHeader(t *testing.T) {
|
||||||
|
|
||||||
func TestPrometheusGeneratesMetricsWithHostNameTag(t *testing.T) {
|
func TestPrometheusGeneratesMetricsWithHostNameTag(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
_, err := fmt.Fprintln(w, sampleTextFormat)
|
if _, err := fmt.Fprintln(w, sampleTextFormat); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
@ -174,8 +189,11 @@ func TestPrometheusWithTimestamp(t *testing.T) {
|
||||||
# TYPE test_counter counter
|
# TYPE test_counter counter
|
||||||
test_counter{label="test"} 1 1685443805885`
|
test_counter{label="test"} 1 1685443805885`
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
_, err := fmt.Fprintln(w, prommetric)
|
if _, err := fmt.Fprintln(w, prommetric); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
@ -210,8 +228,11 @@ func TestPrometheusGeneratesMetricsAlthoughFirstDNSFailsIntegration(t *testing.T
|
||||||
}
|
}
|
||||||
|
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
_, err := fmt.Fprintln(w, sampleTextFormat)
|
if _, err := fmt.Fprintln(w, sampleTextFormat); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
@ -237,8 +258,11 @@ func TestPrometheusGeneratesMetricsAlthoughFirstDNSFailsIntegration(t *testing.T
|
||||||
func TestPrometheusGeneratesMetricsSlowEndpoint(t *testing.T) {
|
func TestPrometheusGeneratesMetricsSlowEndpoint(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
time.Sleep(4 * time.Second)
|
time.Sleep(4 * time.Second)
|
||||||
_, err := fmt.Fprintln(w, sampleTextFormat)
|
if _, err := fmt.Fprintln(w, sampleTextFormat); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
@ -269,8 +293,11 @@ func TestPrometheusGeneratesMetricsSlowEndpoint(t *testing.T) {
|
||||||
func TestPrometheusGeneratesMetricsSlowEndpointHitTheTimeout(t *testing.T) {
|
func TestPrometheusGeneratesMetricsSlowEndpointHitTheTimeout(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
time.Sleep(6 * time.Second)
|
time.Sleep(6 * time.Second)
|
||||||
_, err := fmt.Fprintln(w, sampleTextFormat)
|
if _, err := fmt.Fprintln(w, sampleTextFormat); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
@ -298,8 +325,11 @@ func TestPrometheusGeneratesMetricsSlowEndpointHitTheTimeout(t *testing.T) {
|
||||||
func TestPrometheusGeneratesMetricsSlowEndpointNewConfigParameter(t *testing.T) {
|
func TestPrometheusGeneratesMetricsSlowEndpointNewConfigParameter(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
time.Sleep(4 * time.Second)
|
time.Sleep(4 * time.Second)
|
||||||
_, err := fmt.Fprintln(w, sampleTextFormat)
|
if _, err := fmt.Fprintln(w, sampleTextFormat); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
@ -328,8 +358,11 @@ func TestPrometheusGeneratesMetricsSlowEndpointNewConfigParameter(t *testing.T)
|
||||||
func TestPrometheusGeneratesMetricsSlowEndpointHitTheTimeoutNewConfigParameter(t *testing.T) {
|
func TestPrometheusGeneratesMetricsSlowEndpointHitTheTimeoutNewConfigParameter(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
time.Sleep(6 * time.Second)
|
time.Sleep(6 * time.Second)
|
||||||
_, err := fmt.Fprintln(w, sampleTextFormat)
|
if _, err := fmt.Fprintln(w, sampleTextFormat); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
@ -350,8 +383,11 @@ func TestPrometheusGeneratesMetricsSlowEndpointHitTheTimeoutNewConfigParameter(t
|
||||||
|
|
||||||
func TestPrometheusContentLengthLimit(t *testing.T) {
|
func TestPrometheusContentLengthLimit(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
_, err := fmt.Fprintln(w, sampleTextFormat)
|
if _, err := fmt.Fprintln(w, sampleTextFormat); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
@ -370,8 +406,11 @@ func TestPrometheusContentLengthLimit(t *testing.T) {
|
||||||
|
|
||||||
func TestPrometheusGeneratesSummaryMetricsV2(t *testing.T) {
|
func TestPrometheusGeneratesSummaryMetricsV2(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
_, err := fmt.Fprintln(w, sampleSummaryTextFormat)
|
if _, err := fmt.Fprintln(w, sampleSummaryTextFormat); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
@ -404,8 +443,11 @@ go_gc_duration_seconds_sum 42.0
|
||||||
go_gc_duration_seconds_count 42`
|
go_gc_duration_seconds_count 42`
|
||||||
|
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
_, err := fmt.Fprintln(w, data)
|
if _, err := fmt.Fprintln(w, data); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
@ -473,8 +515,11 @@ go_gc_duration_seconds_count 42`
|
||||||
|
|
||||||
func TestPrometheusGeneratesGaugeMetricsV2(t *testing.T) {
|
func TestPrometheusGeneratesGaugeMetricsV2(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
_, err := fmt.Fprintln(w, sampleGaugeTextFormat)
|
if _, err := fmt.Fprintln(w, sampleGaugeTextFormat); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
@ -499,8 +544,11 @@ func TestPrometheusGeneratesGaugeMetricsV2(t *testing.T) {
|
||||||
|
|
||||||
func TestPrometheusGeneratesMetricsWithIgnoreTimestamp(t *testing.T) {
|
func TestPrometheusGeneratesMetricsWithIgnoreTimestamp(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
_, err := fmt.Fprintln(w, sampleTextFormat)
|
if _, err := fmt.Fprintln(w, sampleTextFormat); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
@ -599,8 +647,11 @@ func TestPrometheusInternalOk(t *testing.T) {
|
||||||
# TYPE test_counter counter
|
# TYPE test_counter counter
|
||||||
test_counter{label="test"} 1 1685443805885`
|
test_counter{label="test"} 1 1685443805885`
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
_, err := fmt.Fprintln(w, prommetric)
|
if _, err := fmt.Fprintln(w, prommetric); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
@ -640,8 +691,11 @@ func TestPrometheusInternalContentBadFormat(t *testing.T) {
|
||||||
# TYPE test_counter counter
|
# TYPE test_counter counter
|
||||||
<body>Flag test</body>`
|
<body>Flag test</body>`
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
_, err := fmt.Fprintln(w, prommetric)
|
if _, err := fmt.Fprintln(w, prommetric); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
@ -726,8 +780,11 @@ go_memstats_heap_alloc_bytes 1.581062048e+09
|
||||||
`
|
`
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
w.Header().Add("Content-Type", "application/openmetrics-text;version=1.0.0")
|
w.Header().Add("Content-Type", "application/openmetrics-text;version=1.0.0")
|
||||||
_, err := w.Write([]byte(data))
|
if _, err := w.Write([]byte(data)); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
@ -775,8 +832,11 @@ func TestOpenmetricsProtobuf(t *testing.T) {
|
||||||
|
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
w.Header().Add("Content-Type", "application/openmetrics-protobuf;version=1.0.0")
|
w.Header().Add("Content-Type", "application/openmetrics-protobuf;version=1.0.0")
|
||||||
_, err := w.Write(data)
|
if _, err := w.Write(data); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
@ -834,8 +894,11 @@ go_memstats_heap_alloc_bytes 1.581062048e+09
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
// Provide a wrong version
|
// Provide a wrong version
|
||||||
w.Header().Add("Content-Type", "application/vnd.google.protobuf; proto=io.prometheus.client.MetricFamily; encoding=delimited")
|
w.Header().Add("Content-Type", "application/vnd.google.protobuf; proto=io.prometheus.client.MetricFamily; encoding=delimited")
|
||||||
_, err := w.Write([]byte(data))
|
if _, err := w.Write([]byte(data)); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,15 +33,23 @@ func TestRabbitMQGeneratesMetricsSet1(t *testing.T) {
|
||||||
case "/api/nodes/rabbit@vagrant-ubuntu-trusty-64/memory":
|
case "/api/nodes/rabbit@vagrant-ubuntu-trusty-64/memory":
|
||||||
jsonFilePath = "testdata/set1/memory.json"
|
jsonFilePath = "testdata/set1/memory.json"
|
||||||
default:
|
default:
|
||||||
http.Error(w, fmt.Sprintf("unknown path %q", r.URL.Path), http.StatusNotFound)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Errorf("unknown path %q", r.URL.Path)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := os.ReadFile(jsonFilePath)
|
data, err := os.ReadFile(jsonFilePath)
|
||||||
require.NoErrorf(t, err, "could not read from data file %s", jsonFilePath)
|
if err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Errorf("Could not read from data file %q: %v", jsonFilePath, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
_, err = w.Write(data)
|
if _, err = w.Write(data); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
@ -244,15 +252,23 @@ func TestRabbitMQGeneratesMetricsSet2(t *testing.T) {
|
||||||
case "/api/nodes/rabbit@rmqserver/memory":
|
case "/api/nodes/rabbit@rmqserver/memory":
|
||||||
jsonFilePath = "testdata/set2/memory.json"
|
jsonFilePath = "testdata/set2/memory.json"
|
||||||
default:
|
default:
|
||||||
http.Error(w, fmt.Sprintf("unknown path %q", r.URL.Path), http.StatusNotFound)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Errorf("unknown path %q", r.URL.Path)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := os.ReadFile(jsonFilePath)
|
data, err := os.ReadFile(jsonFilePath)
|
||||||
require.NoErrorf(t, err, "could not read from data file %s", jsonFilePath)
|
if err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Errorf("Could not read from data file %q: %v", jsonFilePath, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
_, err = w.Write(data)
|
if _, err = w.Write(data); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,7 @@ writing: 200
|
||||||
0.0.0.0:3000 active: 11
|
0.0.0.0:3000 active: 11
|
||||||
0.0.0.0:3000 queued: 12
|
0.0.0.0:3000 queued: 12
|
||||||
/tmp/listen.me active: 13
|
/tmp/listen.me active: 13
|
||||||
/tmp/listen.me queued: 14
|
/tmp/listen.me queued: 14`
|
||||||
`
|
|
||||||
|
|
||||||
// Verify that raindrops tags are properly parsed based on the server
|
// Verify that raindrops tags are properly parsed based on the server
|
||||||
func TestRaindropsTags(t *testing.T) {
|
func TestRaindropsTags(t *testing.T) {
|
||||||
|
|
@ -47,13 +46,17 @@ func TestRaindropsTags(t *testing.T) {
|
||||||
|
|
||||||
func TestRaindropsGeneratesMetrics(t *testing.T) {
|
func TestRaindropsGeneratesMetrics(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
var rsp string
|
if r.URL.Path != "/_raindrops" {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Errorf("Cannot handle request, expected: %q, actual: %q", "/_raindrops", r.URL.Path)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
require.Equal(t, "/_raindrops", r.URL.Path, "Cannot handle request")
|
if _, err := fmt.Fprintln(w, sampleResponse); err != nil {
|
||||||
rsp = sampleResponse
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
_, err := fmt.Fprintln(w, rsp)
|
return
|
||||||
require.NoError(t, err)
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,16 +25,24 @@ func TestRavenDBGeneratesMetricsFull(t *testing.T) {
|
||||||
jsonFilePath = "testdata/indexes_full.json"
|
jsonFilePath = "testdata/indexes_full.json"
|
||||||
case "/admin/monitoring/v1/collections":
|
case "/admin/monitoring/v1/collections":
|
||||||
jsonFilePath = "testdata/collections_full.json"
|
jsonFilePath = "testdata/collections_full.json"
|
||||||
|
|
||||||
default:
|
default:
|
||||||
require.Failf(t, "Cannot handle request for uri %s", r.URL.Path)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Errorf("Cannot handle request for uri %s", r.URL.Path)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := os.ReadFile(jsonFilePath)
|
data, err := os.ReadFile(jsonFilePath)
|
||||||
require.NoErrorf(t, err, "could not read from data file %s", jsonFilePath)
|
if err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Errorf("Could not read from data file %q: %v", jsonFilePath, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
_, err = w.Write(data)
|
if _, err = w.Write(data); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
@ -227,14 +235,23 @@ func TestRavenDBGeneratesMetricsMin(t *testing.T) {
|
||||||
case "/admin/monitoring/v1/collections":
|
case "/admin/monitoring/v1/collections":
|
||||||
jsonFilePath = "testdata/collections_min.json"
|
jsonFilePath = "testdata/collections_min.json"
|
||||||
default:
|
default:
|
||||||
require.Failf(t, "Cannot handle request for uri %s", r.URL.Path)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Errorf("Cannot handle request for uri %s", r.URL.Path)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := os.ReadFile(jsonFilePath)
|
data, err := os.ReadFile(jsonFilePath)
|
||||||
require.NoErrorf(t, err, "could not read from data file %s", jsonFilePath)
|
if err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Errorf("Could not read from data file %q: %v", jsonFilePath, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
_, err = w.Write(data)
|
if _, err = w.Write(data); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,12 @@ import (
|
||||||
func TestRiak(t *testing.T) {
|
func TestRiak(t *testing.T) {
|
||||||
// Create a test server with the const response JSON
|
// Create a test server with the const response JSON
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
|
if _, err := fmt.Fprintln(w, response); err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
_, err := fmt.Fprintln(w, response)
|
|
||||||
require.NoError(t, err)
|
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,8 +15,11 @@ import (
|
||||||
func Test_Gather(t *testing.T) {
|
func Test_Gather(t *testing.T) {
|
||||||
fakeServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
fakeServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
w.Header().Add("Content-Type", "application/json")
|
w.Header().Add("Content-Type", "application/json")
|
||||||
_, err := w.Write([]byte(testJSON))
|
if _, err := w.Write([]byte(testJSON)); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer fakeServer.Close()
|
defer fakeServer.Close()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -121,11 +121,19 @@ func TestCases(t *testing.T) {
|
||||||
|
|
||||||
ts.Config.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts.Config.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
resp, ok := pathToResponse[strings.TrimPrefix(r.URL.Path, "/slurm/v0.0.38/")]
|
resp, ok := pathToResponse[strings.TrimPrefix(r.URL.Path, "/slurm/v0.0.38/")]
|
||||||
require.True(t, ok)
|
if !ok {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Errorf("Expected to have path to response: %s", r.URL.Path)
|
||||||
|
return
|
||||||
|
}
|
||||||
w.Header().Add("Content-Type", "application/json")
|
w.Header().Add("Content-Type", "application/json")
|
||||||
|
|
||||||
|
if _, err := w.Write(resp); err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
_, err := w.Write(resp)
|
|
||||||
require.NoError(t, err)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
// Load the test-specific configuration
|
// Load the test-specific configuration
|
||||||
|
|
|
||||||
|
|
@ -68,8 +68,12 @@ func TestCases(t *testing.T) {
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
_, err := w.Write(page)
|
|
||||||
require.NoError(t, err)
|
if _, err := w.Write(page); err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
require.NotNil(t, server)
|
require.NotNil(t, server)
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
|
||||||
|
|
@ -28,8 +28,11 @@ func TestTengineTags(t *testing.T) {
|
||||||
|
|
||||||
func TestTengineGeneratesMetrics(t *testing.T) {
|
func TestTengineGeneratesMetrics(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
_, err := fmt.Fprintln(w, tengineSampleResponse)
|
if _, err := fmt.Fprintln(w, tengineSampleResponse); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,9 +40,12 @@ var tomcatStatus8 = `<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
func TestHTTPTomcat8(t *testing.T) {
|
func TestHTTPTomcat8(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
|
if _, err := fmt.Fprintln(w, tomcatStatus8); err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
_, err := fmt.Fprintln(w, tomcatStatus8)
|
|
||||||
require.NoError(t, err)
|
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
@ -125,9 +128,12 @@ var tomcatStatus6 = `<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
func TestHTTPTomcat6(t *testing.T) {
|
func TestHTTPTomcat6(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||||
|
if _, err := fmt.Fprintln(w, tomcatStatus6); err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
_, err := fmt.Fprintln(w, tomcatStatus6)
|
|
||||||
require.NoError(t, err)
|
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -113,8 +113,11 @@ func TestBasic(t *testing.T) {
|
||||||
|
|
||||||
fakeServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
fakeServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.URL.Path == "/" {
|
if r.URL.Path == "/" {
|
||||||
_, err := w.Write([]byte(js))
|
if _, err := w.Write([]byte(js)); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
}
|
}
|
||||||
|
|
@ -145,8 +148,11 @@ func TestInvalidJSON(t *testing.T) {
|
||||||
|
|
||||||
fakeServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
fakeServer := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.URL.Path == "/" {
|
if r.URL.Path == "/" {
|
||||||
_, err := w.Write([]byte(js))
|
if _, err := w.Write([]byte(js)); err != nil {
|
||||||
require.NoError(t, err)
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
w.WriteHeader(http.StatusNotFound)
|
w.WriteHeader(http.StatusNotFound)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -76,11 +76,19 @@ func TestVaultStats(t *testing.T) {
|
||||||
t.Run(tt.name, func(t *testing.T) {
|
t.Run(tt.name, func(t *testing.T) {
|
||||||
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
if r.RequestURI == "/v1/sys/metrics" {
|
if r.RequestURI == "/v1/sys/metrics" {
|
||||||
w.WriteHeader(http.StatusOK)
|
|
||||||
responseKeyMetrics, err := os.ReadFile("testdata/response_key_metrics.json")
|
responseKeyMetrics, err := os.ReadFile("testdata/response_key_metrics.json")
|
||||||
require.NoError(t, err)
|
if err != nil {
|
||||||
_, err = fmt.Fprintln(w, string(responseKeyMetrics))
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
require.NoError(t, err)
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err = fmt.Fprintln(w, string(responseKeyMetrics)); err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
defer ts.Close()
|
defer ts.Close()
|
||||||
|
|
@ -157,9 +165,12 @@ func TestRedirect(t *testing.T) {
|
||||||
redirectURL := "http://" + r.Host + "/custom/metrics"
|
redirectURL := "http://" + r.Host + "/custom/metrics"
|
||||||
http.Redirect(w, r, redirectURL, http.StatusTemporaryRedirect)
|
http.Redirect(w, r, redirectURL, http.StatusTemporaryRedirect)
|
||||||
case "/custom/metrics":
|
case "/custom/metrics":
|
||||||
|
if _, err := w.Write(response); err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
_, err := w.Write(response)
|
|
||||||
require.NoError(t, err)
|
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
defer server.Close()
|
defer server.Close()
|
||||||
|
|
|
||||||
|
|
@ -80,21 +80,41 @@ func TestFixedValue(t *testing.T) {
|
||||||
if r.URL.Path == "/api/json/v3/commands/login" {
|
if r.URL.Path == "/api/json/v3/commands/login" {
|
||||||
cookie := &http.Cookie{Name: "sessid", Value: "cookie:123456789"}
|
cookie := &http.Cookie{Name: "sessid", Value: "cookie:123456789"}
|
||||||
http.SetCookie(w, cookie)
|
http.SetCookie(w, cookie)
|
||||||
|
|
||||||
|
if _, err := fmt.Fprintln(w, "authentication succeeded"); err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
_, err := fmt.Fprintln(w, "authentication succeeded")
|
|
||||||
require.NoError(t, err)
|
|
||||||
} else if r.URL.Path == "/api/json/v3/types/bbus" {
|
} else if r.URL.Path == "/api/json/v3/types/bbus" {
|
||||||
sampleGetBBUsResponse, err := os.ReadFile(filepath.Join(testdataDir, "sample_get_bbu_response.json"))
|
sampleGetBBUsResponse, err := os.ReadFile(filepath.Join(testdataDir, "sample_get_bbu_response.json"))
|
||||||
require.NoError(t, err)
|
if err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err = fmt.Fprintln(w, string(sampleGetBBUsResponse)); err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
_, err = fmt.Fprintln(w, string(sampleGetBBUsResponse))
|
|
||||||
require.NoError(t, err)
|
|
||||||
} else if r.URL.Path == "/api/json/v3/types/bbus/987654321abcdef" {
|
} else if r.URL.Path == "/api/json/v3/types/bbus/987654321abcdef" {
|
||||||
sampleBBUResponseOne, err := os.ReadFile(filepath.Join(testdataDir, "sample_bbu_response.json"))
|
sampleBBUResponseOne, err := os.ReadFile(filepath.Join(testdataDir, "sample_bbu_response.json"))
|
||||||
require.NoError(t, err)
|
if err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err = fmt.Fprintln(w, string(sampleBBUResponseOne)); err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
_, err = fmt.Fprintln(w, string(sampleBBUResponseOne))
|
|
||||||
require.NoError(t, err)
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
|
|
@ -154,9 +174,12 @@ func TestAuthenticationFailed(t *testing.T) {
|
||||||
ts := httptest.NewServer(
|
ts := httptest.NewServer(
|
||||||
http.HandlerFunc(
|
http.HandlerFunc(
|
||||||
func(w http.ResponseWriter, _ *http.Request) {
|
func(w http.ResponseWriter, _ *http.Request) {
|
||||||
|
if _, err := fmt.Fprintln(w, "bad request"); err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
t.Error(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
_, err := fmt.Fprintln(w, "bad request")
|
|
||||||
require.NoError(t, err)
|
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue