1
0
mirror of https://github.com/moby/moby.git synced 2025-08-01 05:47:11 +03:00

integration-cli: use constants for http methods

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2019-10-12 20:42:19 +02:00
parent 9ed58987ce
commit 23b6b5a9ae
2 changed files with 7 additions and 7 deletions

View File

@ -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.

View File

@ -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")
} }