mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Stop using deprecated SockRequest
Signed-off-by: Stanislav Bondarenko <stanislav.bondarenko@gmail.com>
This commit is contained in:
parent
cdf870bd0b
commit
0fd5a65428
32 changed files with 1399 additions and 1165 deletions
|
@ -23,11 +23,15 @@ func (s *DockerSuite) TestAPICreateWithInvalidHealthcheckParams(c *check.C) {
|
|||
},
|
||||
}
|
||||
|
||||
status, body, err := request.SockRequest("POST", "/containers/create?name="+name, config, daemonHost())
|
||||
res, body, err := request.Post("/containers/create?name="+name, request.JSONBody(config))
|
||||
c.Assert(err, check.IsNil)
|
||||
c.Assert(status, check.Equals, http.StatusBadRequest)
|
||||
c.Assert(res.StatusCode, check.Equals, http.StatusBadRequest)
|
||||
|
||||
buf, err := request.ReadBody(body)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
expected := fmt.Sprintf("Interval in Healthcheck cannot be less than %s", container.MinimumDuration)
|
||||
c.Assert(getErrorMessage(c, body), checker.Contains, expected)
|
||||
c.Assert(getErrorMessage(c, buf), checker.Contains, expected)
|
||||
|
||||
// test invalid Interval in Healthcheck: larger than 0s but less than 1ms
|
||||
name = "test2"
|
||||
|
@ -39,10 +43,14 @@ func (s *DockerSuite) TestAPICreateWithInvalidHealthcheckParams(c *check.C) {
|
|||
"Retries": int(1000),
|
||||
},
|
||||
}
|
||||
status, body, err = request.SockRequest("POST", "/containers/create?name="+name, config, daemonHost())
|
||||
res, body, err = request.Post("/containers/create?name="+name, request.JSONBody(config))
|
||||
c.Assert(err, check.IsNil)
|
||||
c.Assert(status, check.Equals, http.StatusBadRequest)
|
||||
c.Assert(getErrorMessage(c, body), checker.Contains, expected)
|
||||
|
||||
buf, err = request.ReadBody(body)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
c.Assert(res.StatusCode, check.Equals, http.StatusBadRequest)
|
||||
c.Assert(getErrorMessage(c, buf), checker.Contains, expected)
|
||||
|
||||
// test invalid Timeout in Healthcheck: less than 1ms
|
||||
name = "test3"
|
||||
|
@ -54,11 +62,15 @@ func (s *DockerSuite) TestAPICreateWithInvalidHealthcheckParams(c *check.C) {
|
|||
"Retries": int(1000),
|
||||
},
|
||||
}
|
||||
status, body, err = request.SockRequest("POST", "/containers/create?name="+name, config, daemonHost())
|
||||
res, body, err = request.Post("/containers/create?name="+name, request.JSONBody(config))
|
||||
c.Assert(err, check.IsNil)
|
||||
c.Assert(status, check.Equals, http.StatusBadRequest)
|
||||
c.Assert(res.StatusCode, check.Equals, http.StatusBadRequest)
|
||||
|
||||
buf, err = request.ReadBody(body)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
expected = fmt.Sprintf("Timeout in Healthcheck cannot be less than %s", container.MinimumDuration)
|
||||
c.Assert(getErrorMessage(c, body), checker.Contains, expected)
|
||||
c.Assert(getErrorMessage(c, buf), checker.Contains, expected)
|
||||
|
||||
// test invalid Retries in Healthcheck: less than 0
|
||||
name = "test4"
|
||||
|
@ -70,11 +82,15 @@ func (s *DockerSuite) TestAPICreateWithInvalidHealthcheckParams(c *check.C) {
|
|||
"Retries": int(-10),
|
||||
},
|
||||
}
|
||||
status, body, err = request.SockRequest("POST", "/containers/create?name="+name, config, daemonHost())
|
||||
res, body, err = request.Post("/containers/create?name="+name, request.JSONBody(config))
|
||||
c.Assert(err, check.IsNil)
|
||||
c.Assert(status, check.Equals, http.StatusBadRequest)
|
||||
c.Assert(res.StatusCode, check.Equals, http.StatusBadRequest)
|
||||
|
||||
buf, err = request.ReadBody(body)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
expected = "Retries in Healthcheck cannot be negative"
|
||||
c.Assert(getErrorMessage(c, body), checker.Contains, expected)
|
||||
c.Assert(getErrorMessage(c, buf), checker.Contains, expected)
|
||||
|
||||
// test invalid StartPeriod in Healthcheck: not 0 and less than 1ms
|
||||
name = "test3"
|
||||
|
@ -87,9 +103,13 @@ func (s *DockerSuite) TestAPICreateWithInvalidHealthcheckParams(c *check.C) {
|
|||
"StartPeriod": 100 * time.Microsecond,
|
||||
},
|
||||
}
|
||||
status, body, err = request.SockRequest("POST", "/containers/create?name="+name, config, daemonHost())
|
||||
res, body, err = request.Post("/containers/create?name="+name, request.JSONBody(config))
|
||||
c.Assert(err, check.IsNil)
|
||||
c.Assert(status, check.Equals, http.StatusBadRequest)
|
||||
c.Assert(res.StatusCode, check.Equals, http.StatusBadRequest)
|
||||
|
||||
buf, err = request.ReadBody(body)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
expected = fmt.Sprintf("StartPeriod in Healthcheck cannot be less than %s", container.MinimumDuration)
|
||||
c.Assert(getErrorMessage(c, body), checker.Contains, expected)
|
||||
c.Assert(getErrorMessage(c, buf), checker.Contains, expected)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue