Browse code

pkg/plugins: use constants for http methods

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2019/10/13 03:44:07
Showing 4 changed files
... ...
@@ -70,7 +70,7 @@ func TestEchoInputOutput(t *testing.T) {
70 70
 	m := Manifest{[]string{"VolumeDriver", "NetworkDriver"}}
71 71
 
72 72
 	mux.HandleFunc("/Test.Echo", func(w http.ResponseWriter, r *http.Request) {
73
-		if r.Method != "POST" {
73
+		if r.Method != http.MethodPost {
74 74
 			t.Fatalf("Expected POST, got %s\n", r.Method)
75 75
 		}
76 76
 
... ...
@@ -185,7 +185,7 @@ func TestClientStream(t *testing.T) {
185 185
 	var output Manifest
186 186
 
187 187
 	mux.HandleFunc("/Test.Echo", func(w http.ResponseWriter, r *http.Request) {
188
-		if r.Method != "POST" {
188
+		if r.Method != http.MethodPost {
189 189
 			t.Fatalf("Expected POST, got %s", r.Method)
190 190
 		}
191 191
 
... ...
@@ -218,7 +218,7 @@ func TestClientSendFile(t *testing.T) {
218 218
 		t.Fatal(err)
219 219
 	}
220 220
 	mux.HandleFunc("/Test.Echo", func(w http.ResponseWriter, r *http.Request) {
221
-		if r.Method != "POST" {
221
+		if r.Method != http.MethodPost {
222 222
 			t.Fatalf("Expected POST, got %s\n", r.Method)
223 223
 		}
224 224
 
... ...
@@ -263,7 +263,7 @@ type testRequestWrapper struct {
263 263
 }
264 264
 
265 265
 func (w *testRequestWrapper) NewRequest(path string, data io.Reader) (*http.Request, error) {
266
-	req, err := http.NewRequest("POST", path, data)
266
+	req, err := http.NewRequest(http.MethodPost, path, data)
267 267
 	if err != nil {
268 268
 		return nil, err
269 269
 	}
... ...
@@ -95,7 +95,7 @@ func TestPluginWithNoManifest(t *testing.T) {
95 95
 	}
96 96
 
97 97
 	mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) {
98
-		if r.Method != "POST" {
98
+		if r.Method != http.MethodPost {
99 99
 			t.Fatalf("Expected POST, got %s\n", r.Method)
100 100
 		}
101 101
 
... ...
@@ -17,5 +17,5 @@ func TestHTTPTransport(t *testing.T) {
17 17
 	if err != nil {
18 18
 		t.Fatal(err)
19 19
 	}
20
-	assert.Check(t, is.Equal("POST", request.Method))
20
+	assert.Check(t, is.Equal(http.MethodPost, request.Method))
21 21
 }
... ...
@@ -27,7 +27,7 @@ func newHTTPRequest(path string, data io.Reader) (*http.Request, error) {
27 27
 	if !strings.HasPrefix(path, "/") {
28 28
 		path = "/" + path
29 29
 	}
30
-	req, err := http.NewRequest("POST", path, data)
30
+	req, err := http.NewRequest(http.MethodPost, path, data)
31 31
 	if err != nil {
32 32
 		return nil, err
33 33
 	}