Merge pull request #36000 from emil2k/fix-container-log-err

Wrap response error for container logs method.
Upstream-commit: 6415f1dcf5c79da853c604733c56b43ae3d18ced
Component: engine
This commit is contained in:
Sebastiaan van Stijn
2018-01-13 03:16:38 +01:00
committed by GitHub
2 changed files with 11 additions and 1 deletions

View File

@ -74,7 +74,7 @@ func (cli *Client) ContainerLogs(ctx context.Context, container string, options
resp, err := cli.get(ctx, "/containers/"+container+"/logs", query, nil)
if err != nil {
return nil, err
return nil, wrapResponseError(err, resp, "container", container)
}
return resp.body, nil
}

View File

@ -18,6 +18,16 @@ import (
"golang.org/x/net/context"
)
func TestContainerLogsNotFoundError(t *testing.T) {
client := &Client{
client: newMockClient(errorMock(http.StatusNotFound, "Not found")),
}
_, err := client.ContainerLogs(context.Background(), "container_id", types.ContainerLogsOptions{})
if !IsErrNotFound(err) {
t.Fatalf("expected a not found error, got %v", err)
}
}
func TestContainerLogsError(t *testing.T) {
client := &Client{
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),