diff --git a/client/checkpoint_create_test.go b/client/checkpoint_create_test.go index 6b37034550..83ed92cb10 100644 --- a/client/checkpoint_create_test.go +++ b/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) } diff --git a/client/checkpoint_delete_test.go b/client/checkpoint_delete_test.go index 3ebdd2ce02..71daa31123 100644 --- a/client/checkpoint_delete_test.go +++ b/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{ diff --git a/client/config_create_test.go b/client/config_create_test.go index 98898e0c7f..f891cee8d2 100644 --- a/client/config_create_test.go +++ b/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{ diff --git a/client/config_remove_test.go b/client/config_remove_test.go index 3912d1bede..48930ddc25 100644 --- a/client/config_remove_test.go +++ b/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{ diff --git a/client/config_update_test.go b/client/config_update_test.go index 2ad5eb8f68..d43e717e5a 100644 --- a/client/config_update_test.go +++ b/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{ diff --git a/client/container_copy_test.go b/client/container_copy_test.go index b0a4ad825c..6154914387 100644 --- a/client/container_copy_test.go +++ b/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() diff --git a/client/container_exec_test.go b/client/container_exec_test.go index c1cee4ed0f..80f514371c 100644 --- a/client/container_exec_test.go +++ b/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 ? diff --git a/client/hijack.go b/client/hijack.go index e77084af64..6f8205501f 100644 --- a/client/hijack.go +++ b/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 } diff --git a/client/image_remove_test.go b/client/image_remove_test.go index acc6bc9177..b3b02ebddb 100644 --- a/client/image_remove_test.go +++ b/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() diff --git a/client/image_tag_test.go b/client/image_tag_test.go index 0298495101..0ed6355335 100644 --- a/client/image_tag_test.go +++ b/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() diff --git a/client/network_connect_test.go b/client/network_connect_test.go index ef509b7929..032d8291be 100644 --- a/client/network_connect_test.go +++ b/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) } diff --git a/client/network_create_test.go b/client/network_create_test.go index 313f53f907..0fccd085ae 100644 --- a/client/network_create_test.go +++ b/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) } diff --git a/client/network_disconnect_test.go b/client/network_disconnect_test.go index 7ec85f9387..3814e4dbbe 100644 --- a/client/network_disconnect_test.go +++ b/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) } diff --git a/client/network_inspect_test.go b/client/network_inspect_test.go index 699bccba67..e804d8dc22 100644 --- a/client/network_inspect_test.go +++ b/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) } diff --git a/client/network_list_test.go b/client/network_list_test.go index 90ae33405d..3e3d094fe8 100644 --- a/client/network_list_test.go +++ b/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() diff --git a/client/network_remove_test.go b/client/network_remove_test.go index f70c8ac16e..df2c3b4479 100644 --- a/client/network_remove_test.go +++ b/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{ diff --git a/client/node_remove_test.go b/client/node_remove_test.go index 5870ba1da3..5570773607 100644 --- a/client/node_remove_test.go +++ b/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") diff --git a/client/node_update_test.go b/client/node_update_test.go index 072297d682..d51df959a5 100644 --- a/client/node_update_test.go +++ b/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{ diff --git a/client/ping.go b/client/ping.go index 90f39ec14f..1cfc48a25d 100644 --- a/client/ping.go +++ b/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 } diff --git a/client/ping_test.go b/client/ping_test.go index 5b6a33cb1f..e14933a401 100644 --- a/client/ping_test.go +++ b/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, diff --git a/client/plugin_disable_test.go b/client/plugin_disable_test.go index 2e9c0396cc..1b1fe1ba33 100644 --- a/client/plugin_disable_test.go +++ b/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{ diff --git a/client/plugin_enable_test.go b/client/plugin_enable_test.go index 1c3c988d3f..cd1945d751 100644 --- a/client/plugin_enable_test.go +++ b/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{ diff --git a/client/plugin_push_test.go b/client/plugin_push_test.go index 779d8f8e90..b9292e4785 100644 --- a/client/plugin_push_test.go +++ b/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") diff --git a/client/plugin_remove_test.go b/client/plugin_remove_test.go index 46d1b96fa9..249c5cd7b3 100644 --- a/client/plugin_remove_test.go +++ b/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{ diff --git a/client/plugin_set_test.go b/client/plugin_set_test.go index eee467c26b..ad8cdb7db5 100644 --- a/client/plugin_set_test.go +++ b/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{ diff --git a/client/request.go b/client/request.go index 144c416369..ee15a46ed0 100644 --- a/client/request.go +++ b/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{}) } diff --git a/client/request_test.go b/client/request_test.go index de563d2c50..8656ddef68 100644 --- a/client/request_test.go +++ b/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) } } diff --git a/client/secret_create_test.go b/client/secret_create_test.go index 23c2449b55..09b4653036 100644 --- a/client/secret_create_test.go +++ b/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{ diff --git a/client/secret_remove_test.go b/client/secret_remove_test.go index c69db4096d..3c0d7d27e7 100644 --- a/client/secret_remove_test.go +++ b/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{ diff --git a/client/secret_update_test.go b/client/secret_update_test.go index c52ae2b8b8..6d6a759ce3 100644 --- a/client/secret_update_test.go +++ b/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{ diff --git a/client/service_create_test.go b/client/service_create_test.go index ef792a38e2..4b80d92722 100644 --- a/client/service_create_test.go +++ b/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{ diff --git a/client/service_remove_test.go b/client/service_remove_test.go index d2379a1366..f358a7b10c 100644 --- a/client/service_remove_test.go +++ b/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{ diff --git a/client/service_update_test.go b/client/service_update_test.go index 9b5d1616f0..bc6c6f7766 100644 --- a/client/service_update_test.go +++ b/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") diff --git a/client/swarm_get_unlock_key_test.go b/client/swarm_get_unlock_key_test.go index a1e460c1dc..730df7b744 100644 --- a/client/swarm_get_unlock_key_test.go +++ b/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) } diff --git a/client/swarm_init_test.go b/client/swarm_init_test.go index 78b8245461..a1acc69ff2 100644 --- a/client/swarm_init_test.go +++ b/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{ diff --git a/client/swarm_join_test.go b/client/swarm_join_test.go index 215483830b..9cd516c477 100644 --- a/client/swarm_join_test.go +++ b/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{ diff --git a/client/swarm_leave_test.go b/client/swarm_leave_test.go index b5484b3382..36e4fe4003 100644 --- a/client/swarm_leave_test.go +++ b/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") diff --git a/client/swarm_unlock_test.go b/client/swarm_unlock_test.go index dbcc870e2d..b01eb07e18 100644 --- a/client/swarm_unlock_test.go +++ b/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{ diff --git a/client/swarm_update_test.go b/client/swarm_update_test.go index 3acad9da8a..98059f1738 100644 --- a/client/swarm_update_test.go +++ b/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{ diff --git a/client/volume_create_test.go b/client/volume_create_test.go index 173fe104e1..f4078c2f00 100644 --- a/client/volume_create_test.go +++ b/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) } diff --git a/client/volume_inspect_test.go b/client/volume_inspect_test.go index 04f00129b7..804411cf2d 100644 --- a/client/volume_inspect_test.go +++ b/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) diff --git a/client/volume_remove_test.go b/client/volume_remove_test.go index 762e046c11..73d5a2ddfd 100644 --- a/client/volume_remove_test.go +++ b/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{