Browse code

Wrap response error for container logs method.

Signed-off-by: Emil Davtyan <emil2k@gmail.com>

Emil Davtyan authored on 2018/01/13 00:43:09
Showing 2 changed files
... ...
@@ -74,7 +74,7 @@ func (cli *Client) ContainerLogs(ctx context.Context, container string, options
74 74
 
75 75
 	resp, err := cli.get(ctx, "/containers/"+container+"/logs", query, nil)
76 76
 	if err != nil {
77
-		return nil, err
77
+		return nil, wrapResponseError(err, resp, "container", container)
78 78
 	}
79 79
 	return resp.body, nil
80 80
 }
... ...
@@ -18,6 +18,16 @@ import (
18 18
 	"golang.org/x/net/context"
19 19
 )
20 20
 
21
+func TestContainerLogsNotFoundError(t *testing.T) {
22
+	client := &Client{
23
+		client: newMockClient(errorMock(http.StatusNotFound, "Not found")),
24
+	}
25
+	_, err := client.ContainerLogs(context.Background(), "container_id", types.ContainerLogsOptions{})
26
+	if !IsErrNotFound(err) {
27
+		t.Fatalf("expected a not found error, got %v", err)
28
+	}
29
+}
30
+
21 31
 func TestContainerLogsError(t *testing.T) {
22 32
 	client := &Client{
23 33
 		client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),