diff options
author | Vincent Demeester <vincent@sbr.pm> | 2016-12-30 10:49:36 +0100 |
---|---|---|
committer | Vincent Demeester <vincent@sbr.pm> | 2017-01-03 11:49:30 +0100 |
commit | d69d4799a312dfcae63442e290ae6667afd1a038 (patch) | |
tree | 74d4951b19ec0e7a36c44c7d12238fac0d0d13d5 /integration-cli/docker_api_build_test.go | |
parent | de709ebfd891ca44db35353f800d674a8e09a18e (diff) | |
download | docker-d69d4799a312dfcae63442e290ae6667afd1a038.tar.gz |
Add a new request package in integration-cli
The goal is to remove function from `docker_utils.go` and setup
simple, one-responsability package that can be well tested ; and to
ease writing request.
This moves all the calls to `sockRequest` (and similar methods) to
their counterpart in the `request` package.
This introduce `request.Do` to write easier request (with functional
argument to easily augment the request) with some pre-defined function
for the most used http method (i.e. `request.Get`, `request.Post` and
`request.Delete`).
Few of the `sockRequest` call have been moved to `request.Do` (and
`Get`, etc.) to showcase the usage of the package. There is still a
whole lot to do.
Signed-off-by: Vincent Demeester <vincent@sbr.pm>
Diffstat (limited to 'integration-cli/docker_api_build_test.go')
-rw-r--r-- | integration-cli/docker_api_build_test.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/integration-cli/docker_api_build_test.go b/integration-cli/docker_api_build_test.go index 3ff9d18818..68eadca88e 100644 --- a/integration-cli/docker_api_build_test.go +++ b/integration-cli/docker_api_build_test.go @@ -8,6 +8,7 @@ import ( "strings" "github.com/docker/docker/integration-cli/checker" + "github.com/docker/docker/integration-cli/request" "github.com/docker/docker/pkg/testutil" "github.com/go-check/check" ) @@ -31,7 +32,7 @@ RUN find /tmp/` c.Assert(err, checker.IsNil) defer server.Close() - res, body, err := sockRequestRaw("POST", "/build?dockerfile=baz&remote="+server.URL()+"/testD", nil, "application/json") + res, body, err := request.SockRequestRaw("POST", "/build?dockerfile=baz&remote="+server.URL()+"/testD", nil, "application/json", daemonHost()) c.Assert(err, checker.IsNil) c.Assert(res.StatusCode, checker.Equals, http.StatusOK) @@ -72,7 +73,7 @@ func (s *DockerSuite) TestBuildAPIRemoteTarballContext(c *check.C) { defer server.Close() - res, b, err := sockRequestRaw("POST", "/build?remote="+server.URL()+"/testT.tar", nil, "application/tar") + res, b, err := request.SockRequestRaw("POST", "/build?remote="+server.URL()+"/testT.tar", nil, "application/tar", daemonHost()) c.Assert(err, checker.IsNil) c.Assert(res.StatusCode, checker.Equals, http.StatusOK) b.Close() @@ -121,7 +122,7 @@ RUN echo 'right' defer server.Close() url := "/build?dockerfile=custom&remote=" + server.URL() + "/testT.tar" - res, body, err := sockRequestRaw("POST", url, nil, "application/tar") + res, body, err := request.SockRequestRaw("POST", url, nil, "application/tar", daemonHost()) c.Assert(err, checker.IsNil) c.Assert(res.StatusCode, checker.Equals, http.StatusOK) @@ -141,7 +142,7 @@ RUN echo from dockerfile`, c.Assert(err, checker.IsNil) defer git.Close() - res, body, err := sockRequestRaw("POST", "/build?remote="+git.RepoURL, nil, "application/json") + res, body, err := request.SockRequestRaw("POST", "/build?remote="+git.RepoURL, nil, "application/json", daemonHost()) c.Assert(err, checker.IsNil) c.Assert(res.StatusCode, checker.Equals, http.StatusOK) @@ -163,7 +164,7 @@ RUN echo from Dockerfile`, defer git.Close() // Make sure it tries to 'dockerfile' query param value - res, body, err := sockRequestRaw("POST", "/build?dockerfile=baz&remote="+git.RepoURL, nil, "application/json") + res, body, err := request.SockRequestRaw("POST", "/build?dockerfile=baz&remote="+git.RepoURL, nil, "application/json", daemonHost()) c.Assert(err, checker.IsNil) c.Assert(res.StatusCode, checker.Equals, http.StatusOK) @@ -186,7 +187,7 @@ RUN echo from dockerfile`, defer git.Close() // Make sure it tries to 'dockerfile' query param value - res, body, err := sockRequestRaw("POST", "/build?remote="+git.RepoURL, nil, "application/json") + res, body, err := request.SockRequestRaw("POST", "/build?remote="+git.RepoURL, nil, "application/json", daemonHost()) c.Assert(err, checker.IsNil) c.Assert(res.StatusCode, checker.Equals, http.StatusOK) @@ -233,7 +234,7 @@ func (s *DockerSuite) TestBuildAPIUnnormalizedTarPaths(c *check.C) { // failed to close tar archive c.Assert(tw.Close(), checker.IsNil) - res, body, err := sockRequestRaw("POST", "/build", buffer, "application/x-tar") + res, body, err := request.SockRequestRaw("POST", "/build", buffer, "application/x-tar", daemonHost()) c.Assert(err, checker.IsNil) c.Assert(res.StatusCode, checker.Equals, http.StatusOK) |