Wrap response error for container logs method.
Signed-off-by: Emil Davtyan <emil2k@gmail.com>
This commit is contained in:
parent
92309e34e4
commit
2d6fb87ca4
2 changed files with 11 additions and 1 deletions
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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")),
|
||||
|
|
Loading…
Reference in a new issue