Use method constants from the http package
Signed-off-by: beorn7 <beorn@grafana.com>
This commit is contained in:
parent
9a1440d469
commit
48cd700822
|
@ -117,14 +117,14 @@ func New(url, job string) *Pusher {
|
||||||
// Push returns the first error encountered by any method call (including this
|
// Push returns the first error encountered by any method call (including this
|
||||||
// one) in the lifetime of the Pusher.
|
// one) in the lifetime of the Pusher.
|
||||||
func (p *Pusher) Push() error {
|
func (p *Pusher) Push() error {
|
||||||
return p.push("PUT")
|
return p.push(http.MethodPut)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add works like push, but only previously pushed metrics with the same name
|
// Add works like push, but only previously pushed metrics with the same name
|
||||||
// (and the same job and other grouping labels) will be replaced. (It uses HTTP
|
// (and the same job and other grouping labels) will be replaced. (It uses HTTP
|
||||||
// method “POST” to push to the Pushgateway.)
|
// method “POST” to push to the Pushgateway.)
|
||||||
func (p *Pusher) Add() error {
|
func (p *Pusher) Add() error {
|
||||||
return p.push("POST")
|
return p.push(http.MethodPost)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Gatherer adds a Gatherer to the Pusher, from which metrics will be gathered
|
// Gatherer adds a Gatherer to the Pusher, from which metrics will be gathered
|
||||||
|
|
|
@ -93,8 +93,8 @@ func TestPush(t *testing.T) {
|
||||||
Push(); err != nil {
|
Push(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if lastMethod != "PUT" {
|
if lastMethod != http.MethodPut {
|
||||||
t.Error("want method PUT for Push, got", lastMethod)
|
t.Errorf("got method %q for Push, want %q", lastMethod, http.MethodPut)
|
||||||
}
|
}
|
||||||
if !bytes.Equal(lastBody, wantBody) {
|
if !bytes.Equal(lastBody, wantBody) {
|
||||||
t.Errorf("got body %v, want %v", lastBody, wantBody)
|
t.Errorf("got body %v, want %v", lastBody, wantBody)
|
||||||
|
@ -110,8 +110,8 @@ func TestPush(t *testing.T) {
|
||||||
Add(); err != nil {
|
Add(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if lastMethod != "POST" {
|
if lastMethod != http.MethodPost {
|
||||||
t.Error("want method POST for Add, got", lastMethod)
|
t.Errorf("got method %q for Add, want %q", lastMethod, http.MethodPost)
|
||||||
}
|
}
|
||||||
if !bytes.Equal(lastBody, wantBody) {
|
if !bytes.Equal(lastBody, wantBody) {
|
||||||
t.Errorf("got body %v, want %v", lastBody, wantBody)
|
t.Errorf("got body %v, want %v", lastBody, wantBody)
|
||||||
|
@ -167,8 +167,8 @@ func TestPush(t *testing.T) {
|
||||||
Push(); err != nil {
|
Push(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if lastMethod != "PUT" {
|
if lastMethod != http.MethodPut {
|
||||||
t.Error("want method PUT for Push, got", lastMethod)
|
t.Errorf("got method %q for Push, want %q", lastMethod, http.MethodPut)
|
||||||
}
|
}
|
||||||
if !bytes.Equal(lastBody, wantBody) {
|
if !bytes.Equal(lastBody, wantBody) {
|
||||||
t.Errorf("got body %v, want %v", lastBody, wantBody)
|
t.Errorf("got body %v, want %v", lastBody, wantBody)
|
||||||
|
@ -182,8 +182,8 @@ func TestPush(t *testing.T) {
|
||||||
Add(); err != nil {
|
Add(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if lastMethod != "POST" {
|
if lastMethod != http.MethodPost {
|
||||||
t.Error("want method POST for Add, got", lastMethod)
|
t.Errorf("got method %q for Add, want %q", lastMethod, http.MethodPost)
|
||||||
}
|
}
|
||||||
if !bytes.Equal(lastBody, wantBody) {
|
if !bytes.Equal(lastBody, wantBody) {
|
||||||
t.Errorf("got body %v, want %v", lastBody, wantBody)
|
t.Errorf("got body %v, want %v", lastBody, wantBody)
|
||||||
|
@ -199,8 +199,8 @@ func TestPush(t *testing.T) {
|
||||||
Delete(); err != nil {
|
Delete(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if lastMethod != "DELETE" {
|
if lastMethod != http.MethodDelete {
|
||||||
t.Error("want method DELETE for delete, got", lastMethod)
|
t.Errorf("got method %q for Delete, want %q", lastMethod, http.MethodDelete)
|
||||||
}
|
}
|
||||||
if len(lastBody) != 0 {
|
if len(lastBody) != 0 {
|
||||||
t.Errorf("got body of length %d, want empty body", len(lastBody))
|
t.Errorf("got body of length %d, want empty body", len(lastBody))
|
||||||
|
|
Loading…
Reference in New Issue