Signed-off-by: Krasi Georgiev <krasi@vip-consult.solutions>
| ... | ... |
@@ -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" |
| ... | ... |
@@ -19,6 +20,9 @@ func (cli *Client) CheckpointList(ctx context.Context, container string, options |
| 19 | 19 |
|
| 20 | 20 |
resp, err := cli.get(ctx, "/containers/"+container+"/checkpoints", query, nil) |
| 21 | 21 |
if err != nil {
|
| 22 |
+ if resp.statusCode == http.StatusNotFound {
|
|
| 23 |
+ return checkpoints, containerNotFoundError{container}
|
|
| 24 |
+ } |
|
| 22 | 25 |
return checkpoints, err |
| 23 | 26 |
} |
| 24 | 27 |
|
| ... | ... |
@@ -55,3 +55,14 @@ func TestCheckpointList(t *testing.T) {
|
| 55 | 55 |
t.Fatalf("expected 1 checkpoint, got %v", checkpoints)
|
| 56 | 56 |
} |
| 57 | 57 |
} |
| 58 |
+ |
|
| 59 |
+func TestCheckpointListContainerNotFound(t *testing.T) {
|
|
| 60 |
+ client := &Client{
|
|
| 61 |
+ client: newMockClient(errorMock(http.StatusNotFound, "Server error")), |
|
| 62 |
+ } |
|
| 63 |
+ |
|
| 64 |
+ _, err := client.CheckpointList(context.Background(), "unknown", types.CheckpointListOptions{})
|
|
| 65 |
+ if err == nil || !IsErrContainerNotFound(err) {
|
|
| 66 |
+ t.Fatalf("expected a containerNotFound error, got %v", err)
|
|
| 67 |
+ } |
|
| 68 |
+} |