1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

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

Wrap response error for container logs method.
This commit is contained in:
Sebastiaan van Stijn 2018-01-13 03:16:38 +01:00 committed by GitHub
commit 6415f1dcf5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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")),