Pārlūkot izejas kodu

client: use constants for http methods

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn 5 gadi atpakaļ
vecāks
revīzija
dabc7cdb56
42 mainītis faili ar 54 papildinājumiem un 54 dzēšanām
  1. 1 1
      client/checkpoint_create_test.go
  2. 1 1
      client/checkpoint_delete_test.go
  3. 1 1
      client/config_create_test.go
  4. 1 1
      client/config_remove_test.go
  5. 1 1
      client/config_update_test.go
  6. 3 3
      client/container_copy_test.go
  7. 1 1
      client/container_exec_test.go
  8. 2 2
      client/hijack.go
  9. 1 1
      client/image_remove_test.go
  10. 1 1
      client/image_tag_test.go
  11. 2 2
      client/network_connect_test.go
  12. 1 1
      client/network_create_test.go
  13. 1 1
      client/network_disconnect_test.go
  14. 1 1
      client/network_inspect_test.go
  15. 1 1
      client/network_list_test.go
  16. 1 1
      client/network_remove_test.go
  17. 1 1
      client/node_remove_test.go
  18. 1 1
      client/node_update_test.go
  19. 2 2
      client/ping.go
  20. 2 2
      client/ping_test.go
  21. 1 1
      client/plugin_disable_test.go
  22. 1 1
      client/plugin_enable_test.go
  23. 1 1
      client/plugin_push_test.go
  24. 1 1
      client/plugin_remove_test.go
  25. 1 1
      client/plugin_set_test.go
  26. 7 7
      client/request.go
  27. 1 1
      client/request_test.go
  28. 1 1
      client/secret_create_test.go
  29. 1 1
      client/secret_remove_test.go
  30. 1 1
      client/secret_update_test.go
  31. 1 1
      client/service_create_test.go
  32. 1 1
      client/service_remove_test.go
  33. 1 1
      client/service_update_test.go
  34. 1 1
      client/swarm_get_unlock_key_test.go
  35. 1 1
      client/swarm_init_test.go
  36. 1 1
      client/swarm_join_test.go
  37. 1 1
      client/swarm_leave_test.go
  38. 1 1
      client/swarm_unlock_test.go
  39. 1 1
      client/swarm_update_test.go
  40. 1 1
      client/volume_create_test.go
  41. 1 1
      client/volume_inspect_test.go
  42. 1 1
      client/volume_remove_test.go

+ 1 - 1
client/checkpoint_create_test.go

@@ -42,7 +42,7 @@ func TestCheckpointCreate(t *testing.T) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
 
-			if req.Method != "POST" {
+			if req.Method != http.MethodPost {
 				return nil, fmt.Errorf("expected POST method, got %s", req.Method)
 			}
 

+ 1 - 1
client/checkpoint_delete_test.go

@@ -38,7 +38,7 @@ func TestCheckpointDelete(t *testing.T) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
-			if req.Method != "DELETE" {
+			if req.Method != http.MethodDelete {
 				return nil, fmt.Errorf("expected DELETE method, got %s", req.Method)
 			}
 			return &http.Response{

+ 1 - 1
client/config_create_test.go

@@ -48,7 +48,7 @@ func TestConfigCreate(t *testing.T) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
-			if req.Method != "POST" {
+			if req.Method != http.MethodPost {
 				return nil, fmt.Errorf("expected POST method, got %s", req.Method)
 			}
 			b, err := json.Marshal(types.ConfigCreateResponse{

+ 1 - 1
client/config_remove_test.go

@@ -47,7 +47,7 @@ func TestConfigRemove(t *testing.T) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
-			if req.Method != "DELETE" {
+			if req.Method != http.MethodDelete {
 				return nil, fmt.Errorf("expected DELETE method, got %s", req.Method)
 			}
 			return &http.Response{

+ 1 - 1
client/config_update_test.go

@@ -48,7 +48,7 @@ func TestConfigUpdate(t *testing.T) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
-			if req.Method != "POST" {
+			if req.Method != http.MethodPost {
 				return nil, fmt.Errorf("expected POST method, got %s", req.Method)
 			}
 			return &http.Response{

+ 3 - 3
client/container_copy_test.go

@@ -61,7 +61,7 @@ func TestContainerStatPath(t *testing.T) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
-			if req.Method != "HEAD" {
+			if req.Method != http.MethodHead {
 				return nil, fmt.Errorf("expected HEAD method, got %s", req.Method)
 			}
 			query := req.URL.Query()
@@ -140,7 +140,7 @@ func TestCopyToContainer(t *testing.T) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
-			if req.Method != "PUT" {
+			if req.Method != http.MethodPut {
 				return nil, fmt.Errorf("expected PUT method, got %s", req.Method)
 			}
 			query := req.URL.Query()
@@ -235,7 +235,7 @@ func TestCopyFromContainer(t *testing.T) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
-			if req.Method != "GET" {
+			if req.Method != http.MethodGet {
 				return nil, fmt.Errorf("expected GET method, got %s", req.Method)
 			}
 			query := req.URL.Query()

+ 1 - 1
client/container_exec_test.go

@@ -34,7 +34,7 @@ func TestContainerExecCreate(t *testing.T) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 				return nil, fmt.Errorf("expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
-			if req.Method != "POST" {
+			if req.Method != http.MethodPost {
 				return nil, fmt.Errorf("expected POST method, got %s", req.Method)
 			}
 			// FIXME validate the content is the given ExecConfig ?

+ 2 - 2
client/hijack.go

@@ -24,7 +24,7 @@ func (cli *Client) postHijacked(ctx context.Context, path string, query url.Valu
 	}
 
 	apiPath := cli.getAPIPath(ctx, path, query)
-	req, err := http.NewRequest("POST", apiPath, bodyEncoded)
+	req, err := http.NewRequest(http.MethodPost, apiPath, bodyEncoded)
 	if err != nil {
 		return types.HijackedResponse{}, err
 	}
@@ -40,7 +40,7 @@ func (cli *Client) postHijacked(ctx context.Context, path string, query url.Valu
 
 // DialHijack returns a hijacked connection with negotiated protocol proto.
 func (cli *Client) DialHijack(ctx context.Context, url, proto string, meta map[string][]string) (net.Conn, error) {
-	req, err := http.NewRequest("POST", url, nil)
+	req, err := http.NewRequest(http.MethodPost, url, nil)
 	if err != nil {
 		return nil, err
 	}

+ 1 - 1
client/image_remove_test.go

@@ -63,7 +63,7 @@ func TestImageRemove(t *testing.T) {
 				if !strings.HasPrefix(req.URL.Path, expectedURL) {
 					return nil, fmt.Errorf("expected URL '%s', got '%s'", expectedURL, req.URL)
 				}
-				if req.Method != "DELETE" {
+				if req.Method != http.MethodDelete {
 					return nil, fmt.Errorf("expected DELETE method, got %s", req.Method)
 				}
 				query := req.URL.Query()

+ 1 - 1
client/image_tag_test.go

@@ -123,7 +123,7 @@ func TestImageTag(t *testing.T) {
 				if !strings.HasPrefix(req.URL.Path, expectedURL) {
 					return nil, fmt.Errorf("expected URL '%s', got '%s'", expectedURL, req.URL)
 				}
-				if req.Method != "POST" {
+				if req.Method != http.MethodPost {
 					return nil, fmt.Errorf("expected POST method, got %s", req.Method)
 				}
 				query := req.URL.Query()

+ 2 - 2
client/network_connect_test.go

@@ -38,7 +38,7 @@ func TestNetworkConnectEmptyNilEndpointSettings(t *testing.T) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
 
-			if req.Method != "POST" {
+			if req.Method != http.MethodPost {
 				return nil, fmt.Errorf("expected POST method, got %s", req.Method)
 			}
 
@@ -77,7 +77,7 @@ func TestNetworkConnect(t *testing.T) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
 
-			if req.Method != "POST" {
+			if req.Method != http.MethodPost {
 				return nil, fmt.Errorf("expected POST method, got %s", req.Method)
 			}
 

+ 1 - 1
client/network_create_test.go

@@ -37,7 +37,7 @@ func TestNetworkCreate(t *testing.T) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
 
-			if req.Method != "POST" {
+			if req.Method != http.MethodPost {
 				return nil, fmt.Errorf("expected POST method, got %s", req.Method)
 			}
 

+ 1 - 1
client/network_disconnect_test.go

@@ -37,7 +37,7 @@ func TestNetworkDisconnect(t *testing.T) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
 
-			if req.Method != "POST" {
+			if req.Method != http.MethodPost {
 				return nil, fmt.Errorf("expected POST method, got %s", req.Method)
 			}
 

+ 1 - 1
client/network_inspect_test.go

@@ -55,7 +55,7 @@ func TestNetworkInspect(t *testing.T) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
-			if req.Method != "GET" {
+			if req.Method != http.MethodGet {
 				return nil, fmt.Errorf("expected GET method, got %s", req.Method)
 			}
 

+ 1 - 1
client/network_list_test.go

@@ -77,7 +77,7 @@ func TestNetworkList(t *testing.T) {
 				if !strings.HasPrefix(req.URL.Path, expectedURL) {
 					return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 				}
-				if req.Method != "GET" {
+				if req.Method != http.MethodGet {
 					return nil, fmt.Errorf("expected GET method, got %s", req.Method)
 				}
 				query := req.URL.Query()

+ 1 - 1
client/network_remove_test.go

@@ -34,7 +34,7 @@ func TestNetworkRemove(t *testing.T) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
-			if req.Method != "DELETE" {
+			if req.Method != http.MethodDelete {
 				return nil, fmt.Errorf("expected DELETE method, got %s", req.Method)
 			}
 			return &http.Response{

+ 1 - 1
client/node_remove_test.go

@@ -49,7 +49,7 @@ func TestNodeRemove(t *testing.T) {
 				if !strings.HasPrefix(req.URL.Path, expectedURL) {
 					return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 				}
-				if req.Method != "DELETE" {
+				if req.Method != http.MethodDelete {
 					return nil, fmt.Errorf("expected DELETE method, got %s", req.Method)
 				}
 				force := req.URL.Query().Get("force")

+ 1 - 1
client/node_update_test.go

@@ -35,7 +35,7 @@ func TestNodeUpdate(t *testing.T) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
-			if req.Method != "POST" {
+			if req.Method != http.MethodPost {
 				return nil, fmt.Errorf("expected POST method, got %s", req.Method)
 			}
 			return &http.Response{

+ 2 - 2
client/ping.go

@@ -19,7 +19,7 @@ func (cli *Client) Ping(ctx context.Context) (types.Ping, error) {
 	// Using cli.buildRequest() + cli.doRequest() instead of cli.sendRequest()
 	// because ping requests are used during  API version negotiation, so we want
 	// to hit the non-versioned /_ping endpoint, not /v1.xx/_ping
-	req, err := cli.buildRequest("HEAD", path.Join(cli.basePath, "/_ping"), nil, nil)
+	req, err := cli.buildRequest(http.MethodHead, path.Join(cli.basePath, "/_ping"), nil, nil)
 	if err != nil {
 		return ping, err
 	}
@@ -35,7 +35,7 @@ func (cli *Client) Ping(ctx context.Context) (types.Ping, error) {
 		return ping, err
 	}
 
-	req, err = cli.buildRequest("GET", path.Join(cli.basePath, "/_ping"), nil, nil)
+	req, err = cli.buildRequest(http.MethodGet, path.Join(cli.basePath, "/_ping"), nil, nil)
 	if err != nil {
 		return ping, err
 	}

+ 2 - 2
client/ping_test.go

@@ -90,11 +90,11 @@ func TestPingHeadFallback(t *testing.T) {
 	}{
 		{
 			status:   http.StatusOK,
-			expected: "HEAD",
+			expected: http.MethodHead,
 		},
 		{
 			status:   http.StatusInternalServerError,
-			expected: "HEAD",
+			expected: http.MethodHead,
 		},
 		{
 			status:   http.StatusNotFound,

+ 1 - 1
client/plugin_disable_test.go

@@ -35,7 +35,7 @@ func TestPluginDisable(t *testing.T) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
-			if req.Method != "POST" {
+			if req.Method != http.MethodPost {
 				return nil, fmt.Errorf("expected POST method, got %s", req.Method)
 			}
 			return &http.Response{

+ 1 - 1
client/plugin_enable_test.go

@@ -35,7 +35,7 @@ func TestPluginEnable(t *testing.T) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
-			if req.Method != "POST" {
+			if req.Method != http.MethodPost {
 				return nil, fmt.Errorf("expected POST method, got %s", req.Method)
 			}
 			return &http.Response{

+ 1 - 1
client/plugin_push_test.go

@@ -34,7 +34,7 @@ func TestPluginPush(t *testing.T) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
-			if req.Method != "POST" {
+			if req.Method != http.MethodPost {
 				return nil, fmt.Errorf("expected POST method, got %s", req.Method)
 			}
 			auth := req.Header.Get("X-Registry-Auth")

+ 1 - 1
client/plugin_remove_test.go

@@ -35,7 +35,7 @@ func TestPluginRemove(t *testing.T) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
-			if req.Method != "DELETE" {
+			if req.Method != http.MethodDelete {
 				return nil, fmt.Errorf("expected DELETE method, got %s", req.Method)
 			}
 			return &http.Response{

+ 1 - 1
client/plugin_set_test.go

@@ -34,7 +34,7 @@ func TestPluginSet(t *testing.T) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
-			if req.Method != "POST" {
+			if req.Method != http.MethodPost {
 				return nil, fmt.Errorf("expected POST method, got %s", req.Method)
 			}
 			return &http.Response{

+ 7 - 7
client/request.go

@@ -29,12 +29,12 @@ type serverResponse struct {
 
 // head sends an http request to the docker API using the method HEAD.
 func (cli *Client) head(ctx context.Context, path string, query url.Values, headers map[string][]string) (serverResponse, error) {
-	return cli.sendRequest(ctx, "HEAD", path, query, nil, headers)
+	return cli.sendRequest(ctx, http.MethodHead, path, query, nil, headers)
 }
 
 // get sends an http request to the docker API using the method GET with a specific Go context.
 func (cli *Client) get(ctx context.Context, path string, query url.Values, headers map[string][]string) (serverResponse, error) {
-	return cli.sendRequest(ctx, "GET", path, query, nil, headers)
+	return cli.sendRequest(ctx, http.MethodGet, path, query, nil, headers)
 }
 
 // post sends an http request to the docker API using the method POST with a specific Go context.
@@ -43,21 +43,21 @@ func (cli *Client) post(ctx context.Context, path string, query url.Values, obj
 	if err != nil {
 		return serverResponse{}, err
 	}
-	return cli.sendRequest(ctx, "POST", path, query, body, headers)
+	return cli.sendRequest(ctx, http.MethodPost, path, query, body, headers)
 }
 
 func (cli *Client) postRaw(ctx context.Context, path string, query url.Values, body io.Reader, headers map[string][]string) (serverResponse, error) {
-	return cli.sendRequest(ctx, "POST", path, query, body, headers)
+	return cli.sendRequest(ctx, http.MethodPost, path, query, body, headers)
 }
 
 // putRaw sends an http request to the docker API using the method PUT.
 func (cli *Client) putRaw(ctx context.Context, path string, query url.Values, body io.Reader, headers map[string][]string) (serverResponse, error) {
-	return cli.sendRequest(ctx, "PUT", path, query, body, headers)
+	return cli.sendRequest(ctx, http.MethodPut, path, query, body, headers)
 }
 
 // delete sends an http request to the docker API using the method DELETE.
 func (cli *Client) delete(ctx context.Context, path string, query url.Values, headers map[string][]string) (serverResponse, error) {
-	return cli.sendRequest(ctx, "DELETE", path, query, nil, headers)
+	return cli.sendRequest(ctx, http.MethodDelete, path, query, nil, headers)
 }
 
 type headers map[string][]string
@@ -79,7 +79,7 @@ func encodeBody(obj interface{}, headers headers) (io.Reader, headers, error) {
 }
 
 func (cli *Client) buildRequest(method, path string, body io.Reader, headers headers) (*http.Request, error) {
-	expectedPayload := (method == "POST" || method == "PUT")
+	expectedPayload := (method == http.MethodPost || method == http.MethodPut)
 	if expectedPayload && body == nil {
 		body = bytes.NewReader([]byte{})
 	}

+ 1 - 1
client/request_test.go

@@ -73,7 +73,7 @@ func TestSetHostHeader(t *testing.T) {
 			basePath: hostURL.Path,
 		}
 
-		_, err = client.sendRequest(context.Background(), "GET", testURL, nil, nil, nil)
+		_, err = client.sendRequest(context.Background(), http.MethodGet, testURL, nil, nil, nil)
 		assert.NilError(t, err)
 	}
 }

+ 1 - 1
client/secret_create_test.go

@@ -48,7 +48,7 @@ func TestSecretCreate(t *testing.T) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
-			if req.Method != "POST" {
+			if req.Method != http.MethodPost {
 				return nil, fmt.Errorf("expected POST method, got %s", req.Method)
 			}
 			b, err := json.Marshal(types.SecretCreateResponse{

+ 1 - 1
client/secret_remove_test.go

@@ -47,7 +47,7 @@ func TestSecretRemove(t *testing.T) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
-			if req.Method != "DELETE" {
+			if req.Method != http.MethodDelete {
 				return nil, fmt.Errorf("expected DELETE method, got %s", req.Method)
 			}
 			return &http.Response{

+ 1 - 1
client/secret_update_test.go

@@ -48,7 +48,7 @@ func TestSecretUpdate(t *testing.T) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
-			if req.Method != "POST" {
+			if req.Method != http.MethodPost {
 				return nil, fmt.Errorf("expected POST method, got %s", req.Method)
 			}
 			return &http.Response{

+ 1 - 1
client/service_create_test.go

@@ -40,7 +40,7 @@ func TestServiceCreate(t *testing.T) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
-			if req.Method != "POST" {
+			if req.Method != http.MethodPost {
 				return nil, fmt.Errorf("expected POST method, got %s", req.Method)
 			}
 			b, err := json.Marshal(types.ServiceCreateResponse{

+ 1 - 1
client/service_remove_test.go

@@ -40,7 +40,7 @@ func TestServiceRemove(t *testing.T) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
-			if req.Method != "DELETE" {
+			if req.Method != http.MethodDelete {
 				return nil, fmt.Errorf("expected DELETE method, got %s", req.Method)
 			}
 			return &http.Response{

+ 1 - 1
client/service_update_test.go

@@ -58,7 +58,7 @@ func TestServiceUpdate(t *testing.T) {
 				if !strings.HasPrefix(req.URL.Path, expectedURL) {
 					return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 				}
-				if req.Method != "POST" {
+				if req.Method != http.MethodPost {
 					return nil, fmt.Errorf("expected POST method, got %s", req.Method)
 				}
 				version := req.URL.Query().Get("version")

+ 1 - 1
client/swarm_get_unlock_key_test.go

@@ -33,7 +33,7 @@ func TestSwarmGetUnlockKey(t *testing.T) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
-			if req.Method != "GET" {
+			if req.Method != http.MethodGet {
 				return nil, fmt.Errorf("expected GET method, got %s", req.Method)
 			}
 

+ 1 - 1
client/swarm_init_test.go

@@ -35,7 +35,7 @@ func TestSwarmInit(t *testing.T) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
-			if req.Method != "POST" {
+			if req.Method != http.MethodPost {
 				return nil, fmt.Errorf("expected POST method, got %s", req.Method)
 			}
 			return &http.Response{

+ 1 - 1
client/swarm_join_test.go

@@ -35,7 +35,7 @@ func TestSwarmJoin(t *testing.T) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
-			if req.Method != "POST" {
+			if req.Method != http.MethodPost {
 				return nil, fmt.Errorf("expected POST method, got %s", req.Method)
 			}
 			return &http.Response{

+ 1 - 1
client/swarm_leave_test.go

@@ -48,7 +48,7 @@ func TestSwarmLeave(t *testing.T) {
 				if !strings.HasPrefix(req.URL.Path, expectedURL) {
 					return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 				}
-				if req.Method != "POST" {
+				if req.Method != http.MethodPost {
 					return nil, fmt.Errorf("expected POST method, got %s", req.Method)
 				}
 				force := req.URL.Query().Get("force")

+ 1 - 1
client/swarm_unlock_test.go

@@ -35,7 +35,7 @@ func TestSwarmUnlock(t *testing.T) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
-			if req.Method != "POST" {
+			if req.Method != http.MethodPost {
 				return nil, fmt.Errorf("expected POST method, got %s", req.Method)
 			}
 			return &http.Response{

+ 1 - 1
client/swarm_update_test.go

@@ -35,7 +35,7 @@ func TestSwarmUpdate(t *testing.T) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
-			if req.Method != "POST" {
+			if req.Method != http.MethodPost {
 				return nil, fmt.Errorf("expected POST method, got %s", req.Method)
 			}
 			return &http.Response{

+ 1 - 1
client/volume_create_test.go

@@ -38,7 +38,7 @@ func TestVolumeCreate(t *testing.T) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
 
-			if req.Method != "POST" {
+			if req.Method != http.MethodPost {
 				return nil, fmt.Errorf("expected POST method, got %s", req.Method)
 			}
 

+ 1 - 1
client/volume_inspect_test.go

@@ -59,7 +59,7 @@ func TestVolumeInspect(t *testing.T) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
-			if req.Method != "GET" {
+			if req.Method != http.MethodGet {
 				return nil, fmt.Errorf("expected GET method, got %s", req.Method)
 			}
 			content, err := json.Marshal(expected)

+ 1 - 1
client/volume_remove_test.go

@@ -34,7 +34,7 @@ func TestVolumeRemove(t *testing.T) {
 			if !strings.HasPrefix(req.URL.Path, expectedURL) {
 				return nil, fmt.Errorf("Expected URL '%s', got '%s'", expectedURL, req.URL)
 			}
-			if req.Method != "DELETE" {
+			if req.Method != http.MethodDelete {
 				return nil, fmt.Errorf("expected DELETE method, got %s", req.Method)
 			}
 			return &http.Response{