Skip to content

Commit 48cd700

Browse files
committed
Use method constants from the http package
Signed-off-by: beorn7 <[email protected]>
1 parent 9a1440d commit 48cd700

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

prometheus/push/push.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,14 @@ func New(url, job string) *Pusher {
117117
// Push returns the first error encountered by any method call (including this
118118
// one) in the lifetime of the Pusher.
119119
func (p *Pusher) Push() error {
120-
return p.push("PUT")
120+
return p.push(http.MethodPut)
121121
}
122122

123123
// Add works like push, but only previously pushed metrics with the same name
124124
// (and the same job and other grouping labels) will be replaced. (It uses HTTP
125125
// method “POST” to push to the Pushgateway.)
126126
func (p *Pusher) Add() error {
127-
return p.push("POST")
127+
return p.push(http.MethodPost)
128128
}
129129

130130
// Gatherer adds a Gatherer to the Pusher, from which metrics will be gathered

prometheus/push/push_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ func TestPush(t *testing.T) {
9393
Push(); err != nil {
9494
t.Fatal(err)
9595
}
96-
if lastMethod != "PUT" {
97-
t.Error("want method PUT for Push, got", lastMethod)
96+
if lastMethod != http.MethodPut {
97+
t.Errorf("got method %q for Push, want %q", lastMethod, http.MethodPut)
9898
}
9999
if !bytes.Equal(lastBody, wantBody) {
100100
t.Errorf("got body %v, want %v", lastBody, wantBody)
@@ -110,8 +110,8 @@ func TestPush(t *testing.T) {
110110
Add(); err != nil {
111111
t.Fatal(err)
112112
}
113-
if lastMethod != "POST" {
114-
t.Error("want method POST for Add, got", lastMethod)
113+
if lastMethod != http.MethodPost {
114+
t.Errorf("got method %q for Add, want %q", lastMethod, http.MethodPost)
115115
}
116116
if !bytes.Equal(lastBody, wantBody) {
117117
t.Errorf("got body %v, want %v", lastBody, wantBody)
@@ -167,8 +167,8 @@ func TestPush(t *testing.T) {
167167
Push(); err != nil {
168168
t.Fatal(err)
169169
}
170-
if lastMethod != "PUT" {
171-
t.Error("want method PUT for Push, got", lastMethod)
170+
if lastMethod != http.MethodPut {
171+
t.Errorf("got method %q for Push, want %q", lastMethod, http.MethodPut)
172172
}
173173
if !bytes.Equal(lastBody, wantBody) {
174174
t.Errorf("got body %v, want %v", lastBody, wantBody)
@@ -182,8 +182,8 @@ func TestPush(t *testing.T) {
182182
Add(); err != nil {
183183
t.Fatal(err)
184184
}
185-
if lastMethod != "POST" {
186-
t.Error("want method POST for Add, got", lastMethod)
185+
if lastMethod != http.MethodPost {
186+
t.Errorf("got method %q for Add, want %q", lastMethod, http.MethodPost)
187187
}
188188
if !bytes.Equal(lastBody, wantBody) {
189189
t.Errorf("got body %v, want %v", lastBody, wantBody)
@@ -199,8 +199,8 @@ func TestPush(t *testing.T) {
199199
Delete(); err != nil {
200200
t.Fatal(err)
201201
}
202-
if lastMethod != "DELETE" {
203-
t.Error("want method DELETE for delete, got", lastMethod)
202+
if lastMethod != http.MethodDelete {
203+
t.Errorf("got method %q for Delete, want %q", lastMethod, http.MethodDelete)
204204
}
205205
if len(lastBody) != 0 {
206206
t.Errorf("got body of length %d, want empty body", len(lastBody))

0 commit comments

Comments
 (0)