From aa655a4d73693741cd3f8bc44566eb34585b3303 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Sat, 12 Oct 2019 20:44:07 +0200 Subject: [PATCH] pkg/plugins: use constants for http methods Signed-off-by: Sebastiaan van Stijn --- pkg/plugins/client_test.go | 8 ++++---- pkg/plugins/plugin_test.go | 2 +- pkg/plugins/transport/http_test.go | 2 +- pkg/plugins/transport/transport.go | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkg/plugins/client_test.go b/pkg/plugins/client_test.go index 12f67db570..2540ec3561 100644 --- a/pkg/plugins/client_test.go +++ b/pkg/plugins/client_test.go @@ -70,7 +70,7 @@ func TestEchoInputOutput(t *testing.T) { m := Manifest{[]string{"VolumeDriver", "NetworkDriver"}} mux.HandleFunc("/Test.Echo", func(w http.ResponseWriter, r *http.Request) { - if r.Method != "POST" { + if r.Method != http.MethodPost { t.Fatalf("Expected POST, got %s\n", r.Method) } @@ -185,7 +185,7 @@ func TestClientStream(t *testing.T) { var output Manifest mux.HandleFunc("/Test.Echo", func(w http.ResponseWriter, r *http.Request) { - if r.Method != "POST" { + if r.Method != http.MethodPost { t.Fatalf("Expected POST, got %s", r.Method) } @@ -218,7 +218,7 @@ func TestClientSendFile(t *testing.T) { t.Fatal(err) } mux.HandleFunc("/Test.Echo", func(w http.ResponseWriter, r *http.Request) { - if r.Method != "POST" { + if r.Method != http.MethodPost { t.Fatalf("Expected POST, got %s\n", r.Method) } @@ -263,7 +263,7 @@ type testRequestWrapper struct { } func (w *testRequestWrapper) NewRequest(path string, data io.Reader) (*http.Request, error) { - req, err := http.NewRequest("POST", path, data) + req, err := http.NewRequest(http.MethodPost, path, data) if err != nil { return nil, err } diff --git a/pkg/plugins/plugin_test.go b/pkg/plugins/plugin_test.go index ce98078f87..12c35ccbb2 100644 --- a/pkg/plugins/plugin_test.go +++ b/pkg/plugins/plugin_test.go @@ -95,7 +95,7 @@ func TestPluginWithNoManifest(t *testing.T) { } mux.HandleFunc("/Plugin.Activate", func(w http.ResponseWriter, r *http.Request) { - if r.Method != "POST" { + if r.Method != http.MethodPost { t.Fatalf("Expected POST, got %s\n", r.Method) } diff --git a/pkg/plugins/transport/http_test.go b/pkg/plugins/transport/http_test.go index 78ab23724b..2573306cf8 100644 --- a/pkg/plugins/transport/http_test.go +++ b/pkg/plugins/transport/http_test.go @@ -17,5 +17,5 @@ func TestHTTPTransport(t *testing.T) { if err != nil { t.Fatal(err) } - assert.Check(t, is.Equal("POST", request.Method)) + assert.Check(t, is.Equal(http.MethodPost, request.Method)) } diff --git a/pkg/plugins/transport/transport.go b/pkg/plugins/transport/transport.go index 9cb13335a8..6c66cad662 100644 --- a/pkg/plugins/transport/transport.go +++ b/pkg/plugins/transport/transport.go @@ -27,7 +27,7 @@ func newHTTPRequest(path string, data io.Reader) (*http.Request, error) { if !strings.HasPrefix(path, "/") { path = "/" + path } - req, err := http.NewRequest("POST", path, data) + req, err := http.NewRequest(http.MethodPost, path, data) if err != nil { return nil, err }