Explorar o código

integration-cli: use constants for http methods

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn %!s(int64=5) %!d(string=hai) anos
pai
achega
23b6b5a9ae

+ 6 - 6
integration-cli/docker_api_attach_test.go

@@ -142,12 +142,12 @@ func (s *DockerSuite) TestPostContainersAttach(c *testing.T) {
 	cid, _ := dockerCmd(c, "run", "-di", "busybox", "cat")
 	cid, _ := dockerCmd(c, "run", "-di", "busybox", "cat")
 	cid = strings.TrimSpace(cid)
 	cid = strings.TrimSpace(cid)
 	// Attach to the container's stdout stream.
 	// Attach to the container's stdout stream.
-	conn, br, err := sockRequestHijack("POST", "/containers/"+cid+"/attach?stream=1&stdin=1&stdout=1", nil, "text/plain", request.DaemonHost())
+	conn, br, err := sockRequestHijack(http.MethodPost, "/containers/"+cid+"/attach?stream=1&stdin=1&stdout=1", nil, "text/plain", request.DaemonHost())
 	assert.NilError(c, err)
 	assert.NilError(c, err)
 	// Check if the data from stdout can be received.
 	// Check if the data from stdout can be received.
 	expectSuccess(conn, br, "stdout", false)
 	expectSuccess(conn, br, "stdout", false)
 	// Attach to the container's stderr stream.
 	// Attach to the container's stderr stream.
-	conn, br, err = sockRequestHijack("POST", "/containers/"+cid+"/attach?stream=1&stdin=1&stderr=1", nil, "text/plain", request.DaemonHost())
+	conn, br, err = sockRequestHijack(http.MethodPost, "/containers/"+cid+"/attach?stream=1&stdin=1&stderr=1", nil, "text/plain", request.DaemonHost())
 	assert.NilError(c, err)
 	assert.NilError(c, err)
 	// Since the container only emits stdout, attaching to stderr should return nothing.
 	// Since the container only emits stdout, attaching to stderr should return nothing.
 	expectTimeout(conn, br, "stdout")
 	expectTimeout(conn, br, "stdout")
@@ -155,10 +155,10 @@ func (s *DockerSuite) TestPostContainersAttach(c *testing.T) {
 	// Test the similar functions of the stderr stream.
 	// Test the similar functions of the stderr stream.
 	cid, _ = dockerCmd(c, "run", "-di", "busybox", "/bin/sh", "-c", "cat >&2")
 	cid, _ = dockerCmd(c, "run", "-di", "busybox", "/bin/sh", "-c", "cat >&2")
 	cid = strings.TrimSpace(cid)
 	cid = strings.TrimSpace(cid)
-	conn, br, err = sockRequestHijack("POST", "/containers/"+cid+"/attach?stream=1&stdin=1&stderr=1", nil, "text/plain", request.DaemonHost())
+	conn, br, err = sockRequestHijack(http.MethodPost, "/containers/"+cid+"/attach?stream=1&stdin=1&stderr=1", nil, "text/plain", request.DaemonHost())
 	assert.NilError(c, err)
 	assert.NilError(c, err)
 	expectSuccess(conn, br, "stderr", false)
 	expectSuccess(conn, br, "stderr", false)
-	conn, br, err = sockRequestHijack("POST", "/containers/"+cid+"/attach?stream=1&stdin=1&stdout=1", nil, "text/plain", request.DaemonHost())
+	conn, br, err = sockRequestHijack(http.MethodPost, "/containers/"+cid+"/attach?stream=1&stdin=1&stdout=1", nil, "text/plain", request.DaemonHost())
 	assert.NilError(c, err)
 	assert.NilError(c, err)
 	expectTimeout(conn, br, "stderr")
 	expectTimeout(conn, br, "stderr")
 
 
@@ -166,12 +166,12 @@ func (s *DockerSuite) TestPostContainersAttach(c *testing.T) {
 	cid, _ = dockerCmd(c, "run", "-dit", "busybox", "/bin/sh", "-c", "cat >&2")
 	cid, _ = dockerCmd(c, "run", "-dit", "busybox", "/bin/sh", "-c", "cat >&2")
 	cid = strings.TrimSpace(cid)
 	cid = strings.TrimSpace(cid)
 	// Attach to stdout only.
 	// Attach to stdout only.
-	conn, br, err = sockRequestHijack("POST", "/containers/"+cid+"/attach?stream=1&stdin=1&stdout=1", nil, "text/plain", request.DaemonHost())
+	conn, br, err = sockRequestHijack(http.MethodPost, "/containers/"+cid+"/attach?stream=1&stdin=1&stdout=1", nil, "text/plain", request.DaemonHost())
 	assert.NilError(c, err)
 	assert.NilError(c, err)
 	expectSuccess(conn, br, "stdout", true)
 	expectSuccess(conn, br, "stdout", true)
 
 
 	// Attach without stdout stream.
 	// Attach without stdout stream.
-	conn, br, err = sockRequestHijack("POST", "/containers/"+cid+"/attach?stream=1&stdin=1&stderr=1", nil, "text/plain", request.DaemonHost())
+	conn, br, err = sockRequestHijack(http.MethodPost, "/containers/"+cid+"/attach?stream=1&stdin=1&stderr=1", nil, "text/plain", request.DaemonHost())
 	assert.NilError(c, err)
 	assert.NilError(c, err)
 	// Nothing should be received because both the stdout and stderr of the container will be
 	// Nothing should be received because both the stdout and stderr of the container will be
 	// sent to the client as stdout when tty is enabled.
 	// sent to the client as stdout when tty is enabled.

+ 1 - 1
integration-cli/docker_api_exec_resize_test.go

@@ -65,7 +65,7 @@ func (s *DockerSuite) TestExecResizeImmediatelyAfterExecStart(c *testing.T) {
 		}
 		}
 
 
 		payload := bytes.NewBufferString(`{"Tty":true}`)
 		payload := bytes.NewBufferString(`{"Tty":true}`)
-		conn, _, err := sockRequestHijack("POST", fmt.Sprintf("/exec/%s/start", execID), payload, "application/json", request.DaemonHost())
+		conn, _, err := sockRequestHijack(http.MethodPost, fmt.Sprintf("/exec/%s/start", execID), payload, "application/json", request.DaemonHost())
 		if err != nil {
 		if err != nil {
 			return errors.Wrap(err, "failed to start the exec")
 			return errors.Wrap(err, "failed to start the exec")
 		}
 		}