Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>
Arash Deshmeh authored on 2017/08/16 06:16:02... | ... |
@@ -2,6 +2,7 @@ package client |
2 | 2 |
|
3 | 3 |
import ( |
4 | 4 |
"encoding/json" |
5 |
+ "net/http" |
|
5 | 6 |
"net/url" |
6 | 7 |
|
7 | 8 |
"github.com/docker/docker/api/types" |
... | ... |
@@ -21,6 +22,9 @@ func (cli *Client) ImageRemove(ctx context.Context, imageID string, options type |
21 | 21 |
|
22 | 22 |
resp, err := cli.delete(ctx, "/images/"+imageID, query, nil) |
23 | 23 |
if err != nil { |
24 |
+ if resp.statusCode == http.StatusNotFound { |
|
25 |
+ return nil, imageNotFoundError{imageID} |
|
26 |
+ } |
|
24 | 27 |
return nil, err |
25 | 28 |
} |
26 | 29 |
|
... | ... |
@@ -24,6 +24,17 @@ func TestImageRemoveError(t *testing.T) { |
24 | 24 |
} |
25 | 25 |
} |
26 | 26 |
|
27 |
+func TestImageRemoveImageNotFound(t *testing.T) { |
|
28 |
+ client := &Client{ |
|
29 |
+ client: newMockClient(errorMock(http.StatusNotFound, "Server error")), |
|
30 |
+ } |
|
31 |
+ |
|
32 |
+ _, err := client.ImageRemove(context.Background(), "unknown", types.ImageRemoveOptions{}) |
|
33 |
+ if err == nil || !IsErrNotFound(err) { |
|
34 |
+ t.Fatalf("expected an imageNotFoundError error, got %v", err) |
|
35 |
+ } |
|
36 |
+} |
|
37 |
+ |
|
27 | 38 |
func TestImageRemove(t *testing.T) { |
28 | 39 |
expectedURL := "/images/image_id" |
29 | 40 |
removeCases := []struct { |