mirror of https://github.com/docker/cli.git
more descriptive error fo checkpoint ls for non existent containers
Signed-off-by: Krasi Georgiev <krasi@vip-consult.solutions>
This commit is contained in:
parent
c086c9f89c
commit
ba79205e30
|
@ -2,6 +2,7 @@ package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
|
@ -19,6 +20,9 @@ func (cli *Client) CheckpointList(ctx context.Context, container string, options
|
||||||
|
|
||||||
resp, err := cli.get(ctx, "/containers/"+container+"/checkpoints", query, nil)
|
resp, err := cli.get(ctx, "/containers/"+container+"/checkpoints", query, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if resp.statusCode == http.StatusNotFound {
|
||||||
|
return checkpoints, containerNotFoundError{container}
|
||||||
|
}
|
||||||
return checkpoints, err
|
return checkpoints, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,3 +55,14 @@ func TestCheckpointList(t *testing.T) {
|
||||||
t.Fatalf("expected 1 checkpoint, got %v", checkpoints)
|
t.Fatalf("expected 1 checkpoint, got %v", checkpoints)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCheckpointListContainerNotFound(t *testing.T) {
|
||||||
|
client := &Client{
|
||||||
|
client: newMockClient(errorMock(http.StatusNotFound, "Server error")),
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := client.CheckpointList(context.Background(), "unknown", types.CheckpointListOptions{})
|
||||||
|
if err == nil || !IsErrContainerNotFound(err) {
|
||||||
|
t.Fatalf("expected a containerNotFound error, got %v", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue