mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-21 03:16:00 -08:00
use httptest.NewRequest, remove http.ReadRequest (#3557)
This commit is contained in:
parent
330735aca6
commit
35c1926d14
|
@ -14,9 +14,7 @@
|
||||||
package web
|
package web
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
|
||||||
"bytes"
|
"bytes"
|
||||||
"net/http"
|
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -210,22 +208,7 @@ func TestFederation(t *testing.T) {
|
||||||
|
|
||||||
for name, scenario := range scenarios {
|
for name, scenario := range scenarios {
|
||||||
h.config.GlobalConfig.ExternalLabels = scenario.externalLabels
|
h.config.GlobalConfig.ExternalLabels = scenario.externalLabels
|
||||||
req, err := http.ReadRequest(bufio.NewReader(strings.NewReader(
|
req := httptest.NewRequest("GET", "http://example.org/federate?"+scenario.params, nil)
|
||||||
"GET http://example.org/federate?" + scenario.params + " HTTP/1.0\r\n\r\n",
|
|
||||||
)))
|
|
||||||
if err != nil {
|
|
||||||
t.Fatal(err)
|
|
||||||
}
|
|
||||||
// HTTP/1.0 was used above to avoid needing a Host field. Change it to 1.1 here.
|
|
||||||
req.Proto = "HTTP/1.1"
|
|
||||||
req.ProtoMinor = 1
|
|
||||||
req.Close = false
|
|
||||||
// 192.0.2.0/24 is "TEST-NET" in RFC 5737 for use solely in
|
|
||||||
// documentation and example source code and should not be
|
|
||||||
// used publicly.
|
|
||||||
req.RemoteAddr = "192.0.2.1:1234"
|
|
||||||
// TODO(beorn7): Once we are completely on Go1.7, replace the lines above by the following:
|
|
||||||
// req := httptest.NewRequest("GET", "http://example.org/federate?"+scenario.params, nil)
|
|
||||||
res := httptest.NewRecorder()
|
res := httptest.NewRecorder()
|
||||||
h.federation(res, req)
|
h.federation(res, req)
|
||||||
if got, want := res.Code, scenario.code; got != want {
|
if got, want := res.Code, scenario.code; got != want {
|
||||||
|
|
Loading…
Reference in a new issue