mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Ensure body is closed after error is checked
Signed-off-by: Antonio Murdaca <runcom@linux.com>
This commit is contained in:
parent
d593130fda
commit
18faf6f94e
6 changed files with 28 additions and 15 deletions
|
@ -27,7 +27,16 @@ func (s *DockerSuite) TestLogsApiWithStdout(c *check.C) {
|
|||
|
||||
go func() {
|
||||
res, body, err := sockRequestRaw("GET", fmt.Sprintf("/containers/%s/logs?follow=1&stdout=1×tamps=1", id), nil, "")
|
||||
out, _ := bufio.NewReader(body).ReadString('\n')
|
||||
if err != nil {
|
||||
chLog <- logOut{"", nil, err}
|
||||
return
|
||||
}
|
||||
defer body.Close()
|
||||
out, err := bufio.NewReader(body).ReadString('\n')
|
||||
if err != nil {
|
||||
chLog <- logOut{"", nil, err}
|
||||
return
|
||||
}
|
||||
chLog <- logOut{strings.TrimSpace(out), res, err}
|
||||
}()
|
||||
|
||||
|
@ -65,10 +74,8 @@ func (s *DockerSuite) TestLogsApiFollowEmptyOutput(c *check.C) {
|
|||
|
||||
_, body, err := sockRequestRaw("GET", fmt.Sprintf("/containers/%s/logs?follow=1&stdout=1&stderr=1&tail=all", name), bytes.NewBuffer(nil), "")
|
||||
t1 := time.Now()
|
||||
c.Assert(err, check.IsNil)
|
||||
body.Close()
|
||||
if err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
elapsed := t1.Sub(t0).Seconds()
|
||||
if elapsed > 5.0 {
|
||||
c.Fatalf("HTTP response was not immediate (elapsed %.1fs)", elapsed)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue